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.
This commit is contained in:
Guido van Rossum 2001-09-20 20:46:19 +00:00
parent e0af35eb69
commit 6f7993765a
17 changed files with 313 additions and 251 deletions

View file

@ -148,8 +148,9 @@ spamdict_init(spamdictobject *self, PyObject *args, PyObject *kwds)
return 0;
}
static struct memberlist spamdict_members[] = {
{"state", T_INT, offsetof(spamdictobject, state), READONLY},
static PyMemberDef spamdict_members[] = {
{"state", T_INT, offsetof(spamdictobject, state), READONLY,
"an int variable for demonstration purposes"},
{0}
};