##// END OF EJS Templates
Quick fix for #1688, traceback-unicode issue...
Jörgen Stenarson -
Show More
@@ -69,7 +69,7 b' possible inclusion in future releases.'
69 # the file COPYING, distributed as part of this software.
69 # the file COPYING, distributed as part of this software.
70 #*****************************************************************************
70 #*****************************************************************************
71
71
72 from __future__ import with_statement
72 from __future__ import unicode_literals
73
73
74 import inspect
74 import inspect
75 import keyword
75 import keyword
@@ -99,6 +99,7 b' from IPython.core.display_trap import DisplayTrap'
99 from IPython.core.excolors import exception_colors
99 from IPython.core.excolors import exception_colors
100 from IPython.utils import PyColorize
100 from IPython.utils import PyColorize
101 from IPython.utils import io
101 from IPython.utils import io
102 from IPython.utils import path as util_path
102 from IPython.utils import py3compat
103 from IPython.utils import py3compat
103 from IPython.utils import pyfile
104 from IPython.utils import pyfile
104 from IPython.utils.data import uniq_stable
105 from IPython.utils.data import uniq_stable
@@ -282,12 +283,7 b' def _format_traceback_lines(lnum, index, lines, Colors, lvals=None,scheme=None):'
282 _line_format = _parser.format2
283 _line_format = _parser.format2
283
284
284 for line in lines:
285 for line in lines:
285 # FIXME: we need to ensure the source is a pure string at this point,
286 line = py3compat.cast_unicode(line)
286 # else the coloring code makes a royal mess. This is in need of a
287 # serious refactoring, so that all of the ultratb and PyColorize code
288 # is unicode-safe. So for now this is rather an ugly hack, but
289 # necessary to at least have readable tracebacks. Improvements welcome!
290 line = py3compat.cast_bytes_py2(line, 'utf-8')
291
287
292 new_line, err = _line_format(line, 'str', scheme)
288 new_line, err = _line_format(line, 'str', scheme)
293 if not err: line = new_line
289 if not err: line = new_line
@@ -779,7 +775,6 b' class VerboseTB(TBTools):'
779 abspath = os.path.abspath
775 abspath = os.path.abspath
780 for frame, file, lnum, func, lines, index in records:
776 for frame, file, lnum, func, lines, index in records:
781 #print '*** record:',file,lnum,func,lines,index # dbg
777 #print '*** record:',file,lnum,func,lines,index # dbg
782
783 if not file:
778 if not file:
784 file = '?'
779 file = '?'
785 elif not(file.startswith("<") and file.endswith(">")):
780 elif not(file.startswith("<") and file.endswith(">")):
@@ -791,7 +786,7 b' class VerboseTB(TBTools):'
791 # Not sure if this can still happen: abspath now works with
786 # Not sure if this can still happen: abspath now works with
792 # file names like <string>
787 # file names like <string>
793 pass
788 pass
794
789 file = py3compat.cast_unicode(file, util_path.fs_encoding)
795 link = tpl_link % file
790 link = tpl_link % file
796 args, varargs, varkw, locals = inspect.getargvalues(frame)
791 args, varargs, varkw, locals = inspect.getargvalues(frame)
797
792
@@ -30,6 +30,8 b' formatting (which is the hard part).'
30 """
30 """
31 from __future__ import print_function
31 from __future__ import print_function
32
32
33 from __future__ import unicode_literals
34
33 __all__ = ['ANSICodeColors','Parser']
35 __all__ = ['ANSICodeColors','Parser']
34
36
35 _scheme_default = 'Linux'
37 _scheme_default = 'Linux'
General Comments 0
You need to be logged in to leave comments. Login now