diff options
Diffstat (limited to 'Lib/code.py')
| -rw-r--r-- | Lib/code.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/code.py b/Lib/code.py index 25f5b6a..a70d8cc 100644 --- a/Lib/code.py +++ b/Lib/code.py @@ -107,17 +107,16 @@ class InteractiveInterpreter: The output is written by self.write(), below. """ - colorize = kwargs.pop('colorize', False) try: typ, value, tb = sys.exc_info() if filename and issubclass(typ, SyntaxError): value.filename = filename source = kwargs.pop('source', "") - self._showtraceback(typ, value, None, colorize, source) + self._showtraceback(typ, value, None, source) finally: typ = value = tb = None - def showtraceback(self, **kwargs): + def showtraceback(self): """Display the exception that just occurred. We remove the first stack item because it is our own code. @@ -125,14 +124,13 @@ class InteractiveInterpreter: The output is written by self.write(), below. """ - colorize = kwargs.pop('colorize', False) try: typ, value, tb = sys.exc_info() - self._showtraceback(typ, value, tb.tb_next, colorize, '') + self._showtraceback(typ, value, tb.tb_next, '') finally: typ = value = tb = None - def _showtraceback(self, typ, value, tb, colorize, source): + def _showtraceback(self, typ, value, tb, source): sys.last_type = typ sys.last_traceback = tb value = value.with_traceback(tb) @@ -143,9 +141,7 @@ class InteractiveInterpreter: value.text = lines[value.lineno - 1] sys.last_exc = sys.last_value = value = value.with_traceback(tb) if sys.excepthook is sys.__excepthook__: - lines = traceback.format_exception(typ, value, tb, - colorize=colorize) - self.write(''.join(lines)) + self._excepthook(typ, value, tb) else: # If someone has set sys.excepthook, we let that take precedence # over self.write @@ -162,6 +158,12 @@ class InteractiveInterpreter: print('Original exception was:', file=sys.stderr) sys.__excepthook__(typ, value, tb) + def _excepthook(self, typ, value, tb): + # This method is being overwritten in + # _pyrepl.console.InteractiveColoredConsole + lines = traceback.format_exception(typ, value, tb) + self.write(''.join(lines)) + def write(self, data): """Write a string. |
