Add optional docstrings to member descriptors. For backwards
compatibility, this required all places where an array of "struct
memberlist" structures was declared that is referenced from a type's
tp_members slot to change the type of the structure to PyMemberDef;
"struct memberlist" is now only used by old code that still calls
PyMember_Get/Set. The code in PyObject_GenericGetAttr/SetAttr now
calls the new APIs PyMember_GetOne/SetOne, which take a PyMemberDef
argument.
As examples, I added actual docstrings to the attributes of a few
types: file, complex, instance method, super, and xxsubtype.spamlist.
Also converted the symtable to new style getattr.
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index a2ccadb..191dcba 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -625,9 +625,11 @@
{NULL, NULL} /* sentinel */
};
-static struct memberlist complex_members[] = {
- {"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), 0},
- {"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), 0},
+static PyMemberDef complex_members[] = {
+ {"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), 0,
+ "the real part of a complex number"},
+ {"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), 0,
+ "the imaginary part of a complex number"},
{0},
};