Fix for cProfile.

SF patch# 1755176 by Amaury Forgeot d'Arc.
This commit is contained in:
Guido van Rossum 2007-07-16 23:36:05 +00:00
parent d77d6992a5
commit 1c5a98a360
2 changed files with 4 additions and 1 deletions

View File

@ -153,7 +153,7 @@ class Profile(_lsprof.Profiler):
# ____________________________________________________________
def label(code):
if isinstance(code, str):
if isinstance(code, basestring):
return ('~', 0, code) # built-in functions ('~' sorts at the end)
else:
return (code.co_filename, code.co_firstlineno, code.co_name)

View File

@ -182,6 +182,9 @@ normalizeUserObj(PyObject *obj)
if (mod && PyString_Check(mod)) {
modname = PyString_AS_STRING(mod);
}
else if (mod && PyUnicode_Check(mod)) {
modname = PyUnicode_AsString(mod);
}
else if (mod && PyModule_Check(mod)) {
modname = PyModule_GetName(mod);
if (modname == NULL) {