Mercurial > cpython-lru_cache-weakref
diff Objects/methodobject.c @ 8565:19e8016cd38c legacy-trunk
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...)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sat, 27 Jun 1998 18:28:59 +0000 |
| parents | 0369d63b100b |
| children | 9e536dd3dc97 |
line wrap: on
line diff
--- a/Objects/methodobject.c Sat Jun 27 18:25:44 1998 +0000 +++ b/Objects/methodobject.c Sat Jun 27 18:28:59 1998 +0000 @@ -250,8 +250,15 @@ 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++) {
