diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-06-28 03:49:29 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-06-28 03:49:29 (GMT) |
commit | 8477f7af13d080f15b39094a2fa37dcc6314925a (patch) | |
tree | 4fec24fd29fd11b6339489a046e81fec9a382dc5 /Modules/_lsprof.c | |
parent | 0882e27e2aab932369b591d6a30a62bb1f88ad90 (diff) | |
download | cpython-8477f7af13d080f15b39094a2fa37dcc6314925a.zip cpython-8477f7af13d080f15b39094a2fa37dcc6314925a.tar.gz cpython-8477f7af13d080f15b39094a2fa37dcc6314925a.tar.bz2 |
Issue #21863: cProfile now displays the module name of C extension functions, in addition to their own name.
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r-- | Modules/_lsprof.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 0137d95..66e534f 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -202,6 +202,8 @@ normalizeUserObj(PyObject *obj) */ PyObject *self = fn->m_self; PyObject *name = PyUnicode_FromString(fn->m_ml->ml_name); + PyObject *modname = fn->m_module; + if (name != NULL) { PyObject *mo = _PyType_Lookup(Py_TYPE(self), name); Py_XINCREF(mo); @@ -213,9 +215,14 @@ normalizeUserObj(PyObject *obj) return res; } } + /* Otherwise, use __module__ */ PyErr_Clear(); - return PyUnicode_FromFormat("<built-in method %s>", - fn->m_ml->ml_name); + if (modname != NULL && PyUnicode_Check(modname)) + return PyUnicode_FromFormat("<built-in method %S.%s>", + modname, fn->m_ml->ml_name); + else + return PyUnicode_FromFormat("<built-in method %s>", + fn->m_ml->ml_name); } } |