##// END OF EJS Templates
Fix exception color problems in win32....
Fernando Perez -
Show More
@@ -23,7 +23,7 b" name = 'ipython'"
23 23 development = True # change this to False to do a release
24 24 version_base = '0.11'
25 25 branch = 'ipython'
26 revision = '1284'
26 revision = '1312'
27 27
28 28 if development:
29 29 if branch == 'ipython':
@@ -88,7 +88,6 b' import types'
88 88 from inspect import getsourcefile, getfile, getmodule,\
89 89 ismodule, isclass, ismethod, isfunction, istraceback, isframe, iscode
90 90
91
92 91 # IPython's own modules
93 92 # Modified pdb which doesn't damage IPython's readline handling
94 93 from IPython.utils import PyColorize
@@ -312,11 +311,15 b' def _format_traceback_lines(lnum, index, lines, Colors, lvals=None,scheme=None):'
312 311 # Module classes
313 312 class TBTools:
314 313 """Basic tools used by all traceback printer classes."""
314
315 315 #: Default output stream, can be overridden at call time. A special value
316 316 #: of 'stdout' *as a string* can be given to force extraction of sys.stdout
317 317 #: at runtime. This allows testing exception printing with doctests, that
318 318 #: swap sys.stdout just at execution time.
319 out_stream = sys.stderr
319 #: Warning: be VERY careful to set this to one of the Term streams, NEVER
320 #: directly to sys.stdout/err, because under win32 the Term streams come from
321 #: pyreadline and know how to handle color correctly, whie stdout/err don't.
322 out_stream = Term.cerr
320 323
321 324 def __init__(self,color_scheme = 'NoColor',call_pdb=False):
322 325 # Whether to call the interactive pdb debugger after printing
@@ -381,8 +384,7 b' class ListTB(TBTools):'
381 384
382 385 def __call__(self, etype, value, elist):
383 386 Term.cout.flush()
384 print >> Term.cerr, self.text(etype,value,elist)
385 Term.cerr.flush()
387 Term.cerr.writeln(self.text(etype,value,elist))
386 388
387 389 def text(self, etype, value, elist, context=5):
388 390 """Return a color formatted string with the traceback info.
@@ -533,7 +535,7 b' class ListTB(TBTools):'
533 535 # a subclass whose signature or behavior may be different
534 536 Term.cout.flush()
535 537 ostream = sys.stdout if self.out_stream == 'stdout' else Term.cerr
536 print >> ostream, ListTB.text(self, etype, value, []),
538 ostream.write(ListTB.text(self, etype, value, []))
537 539 ostream.flush()
538 540
539 541 def _some_str(self, value):
@@ -907,8 +909,7 b' class VerboseTB(TBTools):'
907 909 (etype, evalue, etb) = info or sys.exc_info()
908 910 self.tb = etb
909 911 Term.cout.flush()
910 print >> Term.cerr, self.text(etype, evalue, etb)
911 Term.cerr.flush()
912 Term.cerr.writeln(self.text(etype, evalue, etb))
912 913
913 914 # Changed so an instance can just be called as VerboseTB_inst() and print
914 915 # out the right info on its own.
@@ -1032,10 +1033,12 b' class AutoFormattedTB(FormattedTB):'
1032 1033 Term.cout.flush()
1033 1034 if tb_offset is not None:
1034 1035 tb_offset, self.tb_offset = self.tb_offset, tb_offset
1035 print >> out, self.text(etype, evalue, etb)
1036 out.write(self.text(etype, evalue, etb))
1037 out.write('\n')
1036 1038 self.tb_offset = tb_offset
1037 1039 else:
1038 print >> out, self.text(etype, evalue, etb)
1040 out.write(self.text(etype, evalue, etb))
1041 out.write('\n')
1039 1042 out.flush()
1040 1043 try:
1041 1044 self.debugger()
General Comments 0
You need to be logged in to leave comments. Login now