diff options
author | Larry Hastings <larry@hastings.org> | 2014-01-24 14:17:25 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2014-01-24 14:17:25 (GMT) |
commit | 5c66189e88034ba807b10422a8750b0c71c4b62b (patch) | |
tree | 541626d6d627396acaccab565e936d35c3b99173 /Objects/descrobject.c | |
parent | b3c0f4067d992fc2c0d8578e308cc7167dc98f32 (diff) | |
download | cpython-5c66189e88034ba807b10422a8750b0c71c4b62b.zip cpython-5c66189e88034ba807b10422a8750b0c71c4b62b.tar.gz cpython-5c66189e88034ba807b10422a8750b0c71c4b62b.tar.bz2 |
Issue #20189: Four additional builtin types (PyTypeObject,
PyMethodDescr_Type, _PyMethodWrapper_Type, and PyWrapperDescr_Type)
have been modified to provide introspection information for builtins.
Also: many additional Lib, test suite, and Argument Clinic fixes.
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r-- | Objects/descrobject.c | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 312fc40..ce1c71b 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -353,11 +353,17 @@ wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds) static PyObject * method_get_doc(PyMethodDescrObject *descr, void *closure) { - if (descr->d_method->ml_doc == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyUnicode_FromString(descr->d_method->ml_doc); + const char *name = descr->d_method->ml_name; + const char *doc = descr->d_method->ml_doc; + return _PyType_GetDocFromInternalDoc(name, doc); +} + +static PyObject * +method_get_text_signature(PyMethodDescrObject *descr, void *closure) +{ + const char *name = descr->d_method->ml_name; + const char *doc = descr->d_method->ml_doc; + return _PyType_GetTextSignatureFromInternalDoc(name, doc); } static PyObject * @@ -425,6 +431,7 @@ static PyMemberDef descr_members[] = { static PyGetSetDef method_getset[] = { {"__doc__", (getter)method_get_doc}, {"__qualname__", (getter)descr_get_qualname}, + {"__text_signature__", (getter)method_get_text_signature}, {0} }; @@ -463,16 +470,23 @@ static PyGetSetDef getset_getset[] = { static PyObject * wrapperdescr_get_doc(PyWrapperDescrObject *descr, void *closure) { - if (descr->d_base->doc == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyUnicode_FromString(descr->d_base->doc); + const char *name = descr->d_base->name; + const char *doc = descr->d_base->doc; + return _PyType_GetDocFromInternalDoc(name, doc); +} + +static PyObject * +wrapperdescr_get_text_signature(PyWrapperDescrObject *descr, void *closure) +{ + const char *name = descr->d_base->name; + const char *doc = descr->d_base->doc; + return _PyType_GetTextSignatureFromInternalDoc(name, doc); } static PyGetSetDef wrapperdescr_getset[] = { {"__doc__", (getter)wrapperdescr_get_doc}, {"__qualname__", (getter)descr_get_qualname}, + {"__text_signature__", (getter)wrapperdescr_get_text_signature}, {0} }; @@ -1143,17 +1157,19 @@ wrapper_name(wrapperobject *wp) } static PyObject * -wrapper_doc(wrapperobject *wp) +wrapper_doc(wrapperobject *wp, void *closure) { - const char *s = wp->descr->d_base->doc; + const char *name = wp->descr->d_base->name; + const char *doc = wp->descr->d_base->doc; + return _PyType_GetDocFromInternalDoc(name, doc); +} - if (s == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - else { - return PyUnicode_FromString(s); - } +static PyObject * +wrapper_text_signature(wrapperobject *wp, void *closure) +{ + const char *name = wp->descr->d_base->name; + const char *doc = wp->descr->d_base->doc; + return _PyType_GetTextSignatureFromInternalDoc(name, doc); } static PyObject * @@ -1167,6 +1183,7 @@ static PyGetSetDef wrapper_getsets[] = { {"__name__", (getter)wrapper_name}, {"__qualname__", (getter)wrapper_qualname}, {"__doc__", (getter)wrapper_doc}, + {"__text_signature__", (getter)wrapper_text_signature}, {0} }; |