mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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:
parent
e0af35eb69
commit
6f7993765a
17 changed files with 313 additions and 251 deletions
|
|
@ -1383,10 +1383,13 @@ static PyMethodDef file_methods[] = {
|
|||
|
||||
#define OFF(x) offsetof(PyFileObject, x)
|
||||
|
||||
static struct memberlist file_memberlist[] = {
|
||||
{"softspace", T_INT, OFF(f_softspace)},
|
||||
{"mode", T_OBJECT, OFF(f_mode), RO},
|
||||
{"name", T_OBJECT, OFF(f_name), RO},
|
||||
static PyMemberDef file_memberlist[] = {
|
||||
{"softspace", T_INT, OFF(f_softspace), 0,
|
||||
"flag indicating that a space needs to be printed; used by print"},
|
||||
{"mode", T_OBJECT, OFF(f_mode), RO,
|
||||
"file mode ('r', 'w', 'a', possibly with 'b' or '+' added)"},
|
||||
{"name", T_OBJECT, OFF(f_name), RO,
|
||||
"file name"},
|
||||
/* getattr(f, "closed") is implemented without this table */
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue