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
This commit is contained in:
CF Bolz-Tereick 2024-08-18 13:28:23 +02:00 committed by GitHub
parent 79c542b5cc
commit 63603bca35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 54 additions and 16 deletions

View file

@ -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: