Show More
@@ -578,7 +578,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
578 | 578 | @observe('colors') |
|
579 | 579 | def init_syntax_highlighting(self, changes=None): |
|
580 | 580 | # Python source parser/formatter for syntax highlighting |
|
581 | pyformat = PyColorize.Parser(style=self.colors).format | |
|
581 | pyformat = PyColorize.Parser(style=self.colors, parent=self).format | |
|
582 | 582 | self.pycolorize = lambda src: pyformat(src,'str') |
|
583 | 583 | |
|
584 | 584 | def refresh_style(self): |
@@ -1569,7 +1569,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
1569 | 1569 | |
|
1570 | 1570 | def init_traceback_handlers(self, custom_exceptions): |
|
1571 | 1571 | # Syntax error handler. |
|
1572 | self.SyntaxTB = ultratb.SyntaxTB(color_scheme='NoColor') | |
|
1572 | self.SyntaxTB = ultratb.SyntaxTB(color_scheme='NoColor', parent=self) | |
|
1573 | 1573 | |
|
1574 | 1574 | # The interactive one is initialized with an offset, meaning we always |
|
1575 | 1575 | # want to remove the topmost item in the traceback, which is our own |
@@ -1578,7 +1578,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
1578 | 1578 | color_scheme='NoColor', |
|
1579 | 1579 | tb_offset = 1, |
|
1580 | 1580 | check_cache=check_linecache_ipython, |
|
1581 | debugger_cls=self.debugger_cls) | |
|
1581 | debugger_cls=self.debugger_cls, parent=self) | |
|
1582 | 1582 | |
|
1583 | 1583 | # The instance will store a pointer to the system-wide exception hook, |
|
1584 | 1584 | # so that runtime code (such as magics) can access it. This is because |
@@ -387,13 +387,11 b' def _fixed_getinnerframes(etb, context=1, tb_offset=0):' | |||
|
387 | 387 | # (SyntaxErrors have to be treated specially because they have no traceback) |
|
388 | 388 | |
|
389 | 389 | |
|
390 |
def _format_traceback_lines(lnum, index, lines, Colors, lvals=None, |
|
|
390 | def _format_traceback_lines(lnum, index, lines, Colors, lvals=None, _line_format=(lambda x,_:x,None)): | |
|
391 | 391 | numbers_width = INDENT_SIZE - 1 |
|
392 | 392 | res = [] |
|
393 | 393 | i = lnum - index |
|
394 | 394 | |
|
395 | _line_format = PyColorize.Parser(style=scheme).format2 | |
|
396 | ||
|
397 | 395 | for line in lines: |
|
398 | 396 | line = py3compat.cast_unicode(line) |
|
399 | 397 | |
@@ -586,9 +584,9 b' class ListTB(TBTools):' | |||
|
586 | 584 | Because they are meant to be called without a full traceback (only a |
|
587 | 585 | list), instances of this class can't call the interactive pdb debugger.""" |
|
588 | 586 | |
|
589 | def __init__(self, color_scheme='NoColor', call_pdb=False, ostream=None, parent=None): | |
|
587 | def __init__(self, color_scheme='NoColor', call_pdb=False, ostream=None, parent=None, config=None): | |
|
590 | 588 | TBTools.__init__(self, color_scheme=color_scheme, call_pdb=call_pdb, |
|
591 | ostream=ostream, parent=parent) | |
|
589 | ostream=ostream, parent=parent,config=config) | |
|
592 | 590 | |
|
593 | 591 | def __call__(self, etype, value, elist): |
|
594 | 592 | self.ostream.flush() |
@@ -801,7 +799,8 b' class VerboseTB(TBTools):' | |||
|
801 | 799 | |
|
802 | 800 | def __init__(self, color_scheme='Linux', call_pdb=False, ostream=None, |
|
803 | 801 | tb_offset=0, long_header=False, include_vars=True, |
|
804 |
check_cache=None, debugger_cls = None |
|
|
802 | check_cache=None, debugger_cls = None, | |
|
803 | parent=None, config=None): | |
|
805 | 804 | """Specify traceback offset, headers and color scheme. |
|
806 | 805 | |
|
807 | 806 | Define how many frames to drop from the tracebacks. Calling it with |
@@ -809,7 +808,7 b' class VerboseTB(TBTools):' | |||
|
809 | 808 | their own code at the top of the traceback (VerboseTB will first |
|
810 | 809 | remove that frame before printing the traceback info).""" |
|
811 | 810 | TBTools.__init__(self, color_scheme=color_scheme, call_pdb=call_pdb, |
|
812 | ostream=ostream) | |
|
811 | ostream=ostream, parent=parent, config=config) | |
|
813 | 812 | self.tb_offset = tb_offset |
|
814 | 813 | self.long_header = long_header |
|
815 | 814 | self.include_vars = include_vars |
@@ -1010,9 +1009,10 b' class VerboseTB(TBTools):' | |||
|
1010 | 1009 | if index is None: |
|
1011 | 1010 | return level |
|
1012 | 1011 | else: |
|
1012 | _line_format = PyColorize.Parser(style=col_scheme, parent=self).format2 | |
|
1013 | 1013 | return '%s%s' % (level, ''.join( |
|
1014 | 1014 | _format_traceback_lines(lnum, index, lines, Colors, lvals, |
|
1015 |
|
|
|
1015 | _line_format))) | |
|
1016 | 1016 | |
|
1017 | 1017 | def prepare_chained_exception_message(self, cause): |
|
1018 | 1018 | direct_cause = "\nThe above exception was the direct cause of the following exception:\n" |
@@ -1277,7 +1277,8 b' class FormattedTB(VerboseTB, ListTB):' | |||
|
1277 | 1277 | def __init__(self, mode='Plain', color_scheme='Linux', call_pdb=False, |
|
1278 | 1278 | ostream=None, |
|
1279 | 1279 | tb_offset=0, long_header=False, include_vars=False, |
|
1280 |
check_cache=None, debugger_cls=None |
|
|
1280 | check_cache=None, debugger_cls=None, | |
|
1281 | parent=None, config=None): | |
|
1281 | 1282 | |
|
1282 | 1283 | # NEVER change the order of this list. Put new modes at the end: |
|
1283 | 1284 | self.valid_modes = ['Plain', 'Context', 'Verbose'] |
@@ -1286,7 +1287,8 b' class FormattedTB(VerboseTB, ListTB):' | |||
|
1286 | 1287 | VerboseTB.__init__(self, color_scheme=color_scheme, call_pdb=call_pdb, |
|
1287 | 1288 | ostream=ostream, tb_offset=tb_offset, |
|
1288 | 1289 | long_header=long_header, include_vars=include_vars, |
|
1289 |
check_cache=check_cache, debugger_cls=debugger_cls |
|
|
1290 | check_cache=check_cache, debugger_cls=debugger_cls, | |
|
1291 | parent=parent, config=config) | |
|
1290 | 1292 | |
|
1291 | 1293 | # Different types of tracebacks are joined with different separators to |
|
1292 | 1294 | # form a single string. They are taken from this dict |
@@ -1415,8 +1417,8 b' class ColorTB(FormattedTB):' | |||
|
1415 | 1417 | class SyntaxTB(ListTB): |
|
1416 | 1418 | """Extension which holds some state: the last exception value""" |
|
1417 | 1419 | |
|
1418 | def __init__(self, color_scheme='NoColor'): | |
|
1419 | ListTB.__init__(self, color_scheme) | |
|
1420 | def __init__(self, color_scheme='NoColor', parent=None, config=None): | |
|
1421 | ListTB.__init__(self, color_scheme, parent=parent, config=config) | |
|
1420 | 1422 | self.last_syntax_error = None |
|
1421 | 1423 | |
|
1422 | 1424 | def __call__(self, etype, value, elist): |
@@ -44,12 +44,7 b' import sys' | |||
|
44 | 44 | import token |
|
45 | 45 | import tokenize |
|
46 | 46 | |
|
47 | try: | |
|
48 | generate_tokens = tokenize.generate_tokens | |
|
49 | except AttributeError: | |
|
50 | # Python 3. Note that we use the undocumented _tokenize because it expects | |
|
51 | # strings, not bytes. See also Python issue #9969. | |
|
52 | generate_tokens = tokenize._tokenize | |
|
47 | generate_tokens = tokenize.generate_tokens | |
|
53 | 48 | |
|
54 | 49 | from IPython.utils.coloransi import TermColors, InputTermColors ,ColorScheme, ColorSchemeTable |
|
55 | 50 | from IPython.utils.py3compat import PY3 |
General Comments 0
You need to be logged in to leave comments.
Login now