From 1c5a98a360093a99136f2a87251aa7c53b87170b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 16 Jul 2007 23:36:05 +0000 Subject: Fix for cProfile. SF patch# 1755176 by Amaury Forgeot d'Arc. --- Lib/cProfile.py | 2 +- Modules/_lsprof.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/cProfile.py b/Lib/cProfile.py index fb434bd..d10b7ab 100755 --- a/Lib/cProfile.py +++ b/Lib/cProfile.py @@ -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) diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index d665f83..6de65b7 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -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) { -- cgit v0.12