summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl/console.py
diff options
context:
space:
mode:
authorCF Bolz-Tereick <cfbolz@gmx.de>2024-08-23 11:59:08 (GMT)
committerGitHub <noreply@github.com>2024-08-23 11:59:08 (GMT)
commit0955db1bd80edf8e20788b95dcfe8580aa0ade19 (patch)
tree485812e0a0656f1b9d7998e46f052761c0e75147 /Lib/_pyrepl/console.py
parent95b4f9c9ad3d7a13442a6874bbcf3683d17723dc (diff)
downloadcpython-0955db1bd80edf8e20788b95dcfe8580aa0ade19.zip
cpython-0955db1bd80edf8e20788b95dcfe8580aa0ade19.tar.gz
cpython-0955db1bd80edf8e20788b95dcfe8580aa0ade19.tar.bz2
[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 63603bca35798c166e1b8e0be76aef69217f8b1b)
Diffstat (limited to 'Lib/_pyrepl/console.py')
-rw-r--r--Lib/_pyrepl/console.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/_pyrepl/console.py b/Lib/_pyrepl/console.py
index f04a1ba..3e72a56 100644
--- a/Lib/_pyrepl/console.py
+++ b/Lib/_pyrepl/console.py
@@ -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: