summaryrefslogtreecommitdiffstats
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r--Modules/_lsprof.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 048cfc8..cc412bf 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -178,7 +178,16 @@ normalizeUserObj(PyObject *obj)
PyObject *mod = fn->m_module;
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 (mod && PyModule_Check(mod)) {
modname = PyModule_GetName(mod);