summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-06-27 18:28:59 (GMT)
committerGuido van Rossum <guido@python.org>1998-06-27 18:28:59 (GMT)
commit8a92c627d96b3548cf0bdcc8ff895d9d4be7b0ff (patch)
tree504a05a0faf623edfcf3c2d1fedf752952e9a9b2 /Objects
parent73d8bff44db83299d5642fc2c57b761aa9feaabf (diff)
downloadcpython-8a92c627d96b3548cf0bdcc8ff895d9d4be7b0ff.zip
cpython-8a92c627d96b3548cf0bdcc8ff895d9d4be7b0ff.tar.gz
cpython-8a92c627d96b3548cf0bdcc8ff895d9d4be7b0ff.tar.bz2
New feature: if the object's type has a non-NULL tp_doc field, that
is returned as the object's __doc__ attribute. (If only the list of methods would be referenced from the type...)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/methodobject.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 7b47c3f..529e2a1 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -250,8 +250,15 @@ Py_FindMethodInChain(chain, self, name)
PyObject *self;
char *name;
{
- if (strcmp(name, "__methods__") == 0)
- return listmethodchain(chain);
+ if (name[0] == '_' && name[1] == '_') {
+ if (strcmp(name, "__methods__") == 0)
+ return listmethodchain(chain);
+ if (strcmp(name, "__doc__") == 0) {
+ char *doc = self->ob_type->tp_doc;
+ if (doc != NULL)
+ return PyString_FromString(doc);
+ }
+ }
while (chain != NULL) {
PyMethodDef *ml = chain->methods;
for (; ml->ml_name != NULL; ml++) {