Index: Modules/_lsprof.c =================================================================== --- Modules/_lsprof.c (revision 56404) +++ Modules/_lsprof.c (working copy) @@ -182,6 +182,9 @@ 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) { Index: Lib/cProfile.py =================================================================== --- Lib/cProfile.py (revision 56404) +++ Lib/cProfile.py (working copy) @@ -153,7 +153,7 @@ # ____________________________________________________________ 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)