From 6f7993765ac0989b5d13084240797913627a31d8 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 20 Sep 2001 20:46:19 +0000 Subject: 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. --- Objects/classobject.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Objects/classobject.c') diff --git a/Objects/classobject.c b/Objects/classobject.c index 3845dfcf74..f8ee6fddad 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -2006,10 +2006,13 @@ PyMethod_New(PyObject *func, PyObject *self, PyObject *class) #define OFF(x) offsetof(PyMethodObject, x) -static struct memberlist instancemethod_memberlist[] = { - {"im_class", T_OBJECT, OFF(im_class), READONLY|RESTRICTED}, - {"im_func", T_OBJECT, OFF(im_func), READONLY|RESTRICTED}, - {"im_self", T_OBJECT, OFF(im_self), READONLY|RESTRICTED}, +static PyMemberDef instancemethod_memberlist[] = { + {"im_class", T_OBJECT, OFF(im_class), READONLY|RESTRICTED, + "the class associated with a method"}, + {"im_func", T_OBJECT, OFF(im_func), READONLY|RESTRICTED, + "the function (or other callable) implementing a method"}, + {"im_self", T_OBJECT, OFF(im_self), READONLY|RESTRICTED, + "the instance to which a method is bound; None for unbound methods"}, {NULL} /* Sentinel */ }; -- cgit v1.2.1