Skip to content

Commit 1c5a98a

Browse files
committed
Fix for cProfile.
SF patch# 1755176 by Amaury Forgeot d'Arc.
1 parent d77d699 commit 1c5a98a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/cProfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def runcall(self, func, *args, **kw):
153153
# ____________________________________________________________
154154

155155
def label(code):
156-
if isinstance(code, str):
156+
if isinstance(code, basestring):
157157
return ('~', 0, code) # built-in functions ('~' sorts at the end)
158158
else:
159159
return (code.co_filename, code.co_firstlineno, code.co_name)

Modules/_lsprof.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ normalizeUserObj(PyObject *obj)
182182
if (mod && PyString_Check(mod)) {
183183
modname = PyString_AS_STRING(mod);
184184
}
185+
else if (mod && PyUnicode_Check(mod)) {
186+
modname = PyUnicode_AsString(mod);
187+
}
185188
else if (mod && PyModule_Check(mod)) {
186189
modname = PyModule_GetName(mod);
187190
if (modname == NULL) {

0 commit comments

Comments
 (0)