summaryrefslogtreecommitdiffstats
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-12-10 18:14:16 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-12-10 18:14:16 (GMT)
commit532d091d058bca2c43b24bc79b53aa70f5caa365 (patch)
treec612fe3a122c30045631831c2b1aa35530e164b7 /Modules/_lsprof.c
parentfc55789cae2db09fe190989943b112fbdc0f5423 (diff)
downloadcpython-532d091d058bca2c43b24bc79b53aa70f5caa365.zip
cpython-532d091d058bca2c43b24bc79b53aa70f5caa365.tar.gz
cpython-532d091d058bca2c43b24bc79b53aa70f5caa365.tar.bz2
Reverted accidental commit (from r87159)
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r--Modules/_lsprof.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 199c42b..cc412bf 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -176,21 +176,31 @@ normalizeUserObj(PyObject *obj)
if (fn->m_self == NULL) {
/* built-in function: look up the module name */
PyObject *mod = fn->m_module;
- PyObject *modname;
- if (mod != NULL) {
- if (PyUnicode_Check(mod)) {
- modname = mod;
- Py_INCREF(modname);
+ const char *modname;
+ if (mod && PyUnicode_Check(mod)) {
+ /* XXX: The following will truncate module names with embedded
+ * null-characters. It is unlikely that this can happen in
+ * practice and the concequences are not serious enough to
+ * introduce extra checks here.
+ */
+ modname = _PyUnicode_AsString(mod);
+ if (modname == NULL) {
+ modname = "<encoding error>";
+ PyErr_Clear();
}
- else if (PyModule_Check(mod)) {
- modname = PyModule_GetNameObject(mod);
- if (modname == NULL)
- PyErr_Clear();
+ }
+ else if (mod && PyModule_Check(mod)) {
+ modname = PyModule_GetName(mod);
+ if (modname == NULL) {
+ PyErr_Clear();
+ modname = "builtins";
}
}
- if (modname != NULL &&
- PyUnicode_CompareWithASCIIString(modname, "builtins") != 0)
- return PyUnicode_FromFormat("<%U.%s>",
+ else {
+ modname = "builtins";
+ }
+ if (strcmp(modname, "builtins") != 0)
+ return PyUnicode_FromFormat("<%s.%s>",
modname,
fn->m_ml->ml_name);
else