From b0d4cc7a89834f05ca94fd02e612baf59c1a510f 2017-05-22 06:44:53 From: Srinivas Reddy Thatiparthy Date: 2017-05-22 06:44:53 Subject: [PATCH] Add --- diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py index c03b8ff..cabb11c 100644 --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -381,6 +381,8 @@ def _format_traceback_lines(lnum, index, lines, Colors, lvals=None, _line_forma i = lnum - index for line in lines: + line = py3compat.cast_unicode(line) + new_line, err = _line_format(line, 'str') if not err: line = new_line @@ -685,7 +687,7 @@ class ListTB(TBTools): have_filedata = False Colors = self.Colors list = [] - stype = Colors.excName + etype.__name__ + Colors.Normal + stype = py3compat.cast_unicode(Colors.excName + etype.__name__ + Colors.Normal) if value is None: # Not sure if this can still happen in Python 2.6 and above list.append(stype + '\n') @@ -701,10 +703,10 @@ class ListTB(TBTools): textline = '' list.append('%s File %s"%s"%s, line %s%s%s\n' % \ (Colors.normalEm, - Colors.filenameEm, value.filename, Colors.normalEm, + Colors.filenameEm, py3compat.cast_unicode(value.filename), Colors.normalEm, Colors.linenoEm, lineno, Colors.Normal )) if textline == '': - textline = value.text + textline = py3compat.cast_unicode(value.text, "utf-8") if textline is not None: i = 0 @@ -769,7 +771,7 @@ class ListTB(TBTools): def _some_str(self, value): # Lifted from traceback.py try: - return str(value) + return py3compat.cast_unicode(str(value)) except: return u'' % type(value).__name__ @@ -866,6 +868,7 @@ class VerboseTB(TBTools): # strange entries... pass + file = py3compat.cast_unicode(file, util_path.fs_encoding) link = tpl_link % util_path.compress_user(file) args, varargs, varkw, locals = inspect.getargvalues(frame) @@ -1043,7 +1046,8 @@ class VerboseTB(TBTools): etype, evalue = str, sys.exc_info()[:2] etype_str, evalue_str = map(str, (etype, evalue)) # ... and format it - return ['%s%s%s: %s' % (colors.excName, etype_str, colorsnormal, evalue_str)] + return ['%s%s%s: %s' % (colors.excName, etype_str, + colorsnormal, py3compat.cast_unicode(evalue_str))] def format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset): """Formats the header, traceback and exception message for a single exception.