From: Guido van Rossum Date: Sat, 27 Jun 1998 18:28:59 +0000 (+0000) Subject: New feature: if the object's type has a non-NULL tp_doc field, that X-Git-Tag: v1.5.2a1~408 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8a92c627d96b3548cf0bdcc8ff895d9d4be7b0ff;p=thirdparty%2FPython%2Fcpython.git 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...) --- diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 7b47c3fb8501..529e2a187015 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++) {