Issue #21863: cProfile now displays the module name of C extension functions, in addition to their own name.

This commit is contained in:
Antoine Pitrou 2014-06-27 23:49:29 -04:00
parent 0882e27e2a
commit 8477f7af13
3 changed files with 17 additions and 7 deletions

View file

@ -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);
}
}