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