summaryrefslogtreecommitdiffstats
path: root/Python/symtable.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 /Python/symtable.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 'Python/symtable.c')
-rw-r--r--Python/symtable.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/Python/symtable.c b/Python/symtable.c
index e115167..4f63ae7 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -106,7 +106,7 @@ ste_dealloc(PySymtableEntryObject *ste)
#define OFF(x) offsetof(PySymtableEntryObject, x)
-static struct memberlist ste_memberlist[] = {
+static PyMemberDef ste_memberlist[] = {
{"id", T_OBJECT, OFF(ste_id), READONLY},
{"name", T_OBJECT, OFF(ste_name), READONLY},
{"symbols", T_OBJECT, OFF(ste_symbols), READONLY},
@@ -119,12 +119,6 @@ static struct memberlist ste_memberlist[] = {
{NULL}
};
-static PyObject *
-ste_getattr(PySymtableEntryObject *ste, char *name)
-{
- return PyMember_Get((char *)ste, ste_memberlist, name);
-}
-
PyTypeObject PySymtableEntry_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
@@ -133,7 +127,7 @@ PyTypeObject PySymtableEntry_Type = {
0,
(destructor)ste_dealloc, /* tp_dealloc */
0, /* tp_print */
- (getattrfunc)ste_getattr, /* tp_getattr */
+ 0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
(reprfunc)ste_repr, /* tp_repr */
@@ -143,9 +137,26 @@ PyTypeObject PySymtableEntry_Type = {
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
- 0, /* tp_getattro */
+ PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ ste_memberlist, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
};