diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py index 8958be2..34908cd 100644 --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -248,7 +248,7 @@ def fix_frame_records_filenames(records): # Look inside the frame's globals dictionary for __file__, # which should be better. However, keep Cython filenames since # we prefer the source filenames over the compiled .so file. - filename = py3compat.cast_unicode(filename, "utf-8") + filename = py3compat.cast_unicode_py2(filename, "utf-8") if not filename.endswith(('.pyx', '.pxd', '.pxi')): better_fn = frame.f_globals.get('__file__', None) if isinstance(better_fn, str): @@ -540,9 +540,9 @@ class ListTB(TBTools): list = [] for filename, lineno, name, line in extracted_list[:-1]: item = ' File %s"%s"%s, line %s%d%s, in %s%s%s\n' % \ - (Colors.filename, py3compat.cast_unicode(filename, "utf-8"), Colors.Normal, + (Colors.filename, py3compat.cast_unicode_py2(filename, "utf-8"), Colors.Normal, Colors.lineno, lineno, Colors.Normal, - Colors.name, py3compat.cast_unicode(name, "utf-8"), Colors.Normal) + Colors.name, py3compat.cast_unicode_py2(name, "utf-8"), Colors.Normal) if line: item += ' %s\n' % line.strip() list.append(item) @@ -550,9 +550,9 @@ class ListTB(TBTools): filename, lineno, name, line = extracted_list[-1] item = '%s File %s"%s"%s, line %s%d%s, in %s%s%s%s\n' % \ (Colors.normalEm, - Colors.filenameEm, py3compat.cast_unicode(filename, "utf-8"), Colors.normalEm, + Colors.filenameEm, py3compat.cast_unicode_py2(filename, "utf-8"), Colors.normalEm, Colors.linenoEm, lineno, Colors.normalEm, - Colors.nameEm, py3compat.cast_unicode(name, "utf-8"), Colors.normalEm, + Colors.nameEm, py3compat.cast_unicode_py2(name, "utf-8"), Colors.normalEm, Colors.Normal) if line: item += '%s %s%s\n' % (Colors.line, line.strip(),