summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl
diff options
context:
space:
mode:
authorCF Bolz-Tereick <cfbolz@gmx.de>2024-08-18 11:28:23 (GMT)
committerGitHub <noreply@github.com>2024-08-18 11:28:23 (GMT)
commit63603bca35798c166e1b8e0be76aef69217f8b1b (patch)
treef86478ea07f33a1d4fb583a5575c28fa0d6a74db /Lib/_pyrepl
parent79c542b5cc774ba758acc2b2e3b6556934190e34 (diff)
downloadcpython-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.py12
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: