]> granicus.if.org Git - python/commitdiff
New feature: if the object's type has a non-NULL tp_doc field, that
authorGuido van Rossum <guido@python.org>
Sat, 27 Jun 1998 18:28:59 +0000 (18:28 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 27 Jun 1998 18:28:59 +0000 (18:28 +0000)
is returned as the object's __doc__ attribute.

(If only the list of methods would be referenced from the type...)

Objects/methodobject.c

index 7b47c3fb850143661c757310dcea1e12e32e0130..529e2a187015ddf1d5e3c29ed4cf4a91f42f4cd7 100644 (file)
@@ -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++) {