summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-20 20:46:19 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-20 20:46:19 (GMT)
commit6f7993765ac0989b5d13084240797913627a31d8 (patch)
tree51dd234049db1eb78c6dd25d23ec687bf91d817c /Objects/fileobject.c
parente0af35eb694179d8da5d3208ffdfb92e5356335f (diff)
downloadcpython-6f7993765ac0989b5d13084240797913627a31d8.zip
cpython-6f7993765ac0989b5d13084240797913627a31d8.tar.gz
cpython-6f7993765ac0989b5d13084240797913627a31d8.tar.bz2
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.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 6ceb83c..5c879ff 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -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 */
};