[3.13] gh-82378 fix sys.tracebacklimit in pyrepl, approach 2 (GH-123062) (#123252)

Make sure that pyrepl uses the same logic for sys.tracebacklimit as both
the basic repl and the standard sys.excepthook
(cherry picked from commit 63603bca35)
This commit is contained in:
CF Bolz-Tereick 2024-08-23 13:59:08 +02:00 committed by GitHub
parent 95b4f9c9ad
commit 0955db1bd8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 53 additions and 12 deletions

View file

@ -164,8 +164,13 @@ class InteractiveColoredConsole(code.InteractiveConsole):
def showsyntaxerror(self, filename=None, **kwargs):
super().showsyntaxerror(filename=filename, **kwargs)
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: