diff options
author | CF Bolz-Tereick <cfbolz@gmx.de> | 2024-08-18 11:28:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-18 11:28:23 (GMT) |
commit | 63603bca35798c166e1b8e0be76aef69217f8b1b (patch) | |
tree | f86478ea07f33a1d4fb583a5575c28fa0d6a74db /Lib/_pyrepl | |
parent | 79c542b5cc774ba758acc2b2e3b6556934190e34 (diff) | |
download | cpython-63603bca35798c166e1b8e0be76aef69217f8b1b.zip cpython-63603bca35798c166e1b8e0be76aef69217f8b1b.tar.gz cpython-63603bca35798c166e1b8e0be76aef69217f8b1b.tar.bz2 |
gh-82378 fix sys.tracebacklimit in pyrepl, approach 2 (#123062)
Make sure that pyrepl uses the same logic for sys.tracebacklimit as both
the basic repl and the standard sys.excepthook
Diffstat (limited to 'Lib/_pyrepl')
-rw-r--r-- | Lib/_pyrepl/console.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/_pyrepl/console.py b/Lib/_pyrepl/console.py index a8d3f52..2b6c6be 100644 --- a/Lib/_pyrepl/console.py +++ b/Lib/_pyrepl/console.py @@ -161,11 +161,13 @@ class InteractiveColoredConsole(code.InteractiveConsole): super().__init__(locals=locals, filename=filename, local_exit=local_exit) # type: ignore[call-arg] self.can_colorize = _colorize.can_colorize() - def showsyntaxerror(self, filename=None): - super().showsyntaxerror(colorize=self.can_colorize) - - def showtraceback(self): - super().showtraceback(colorize=self.can_colorize) + def _excepthook(self, typ, value, tb): + import traceback + lines = traceback.format_exception( + typ, value, tb, + colorize=self.can_colorize, + limit=traceback.BUILTIN_EXCEPTION_LIMIT) + self.write(''.join(lines)) def runsource(self, source, filename="<input>", symbol="single"): try: |