You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The new REPL outputs different tracebeck when custom sys.excepthook is used #122478
If sys.systemhook is not sys.__systemhook__, the new REPL outputs the line in the code module in the traceback:
>>> xxx
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
xxx
NameError: name 'xxx' is not defined
>>> import sys; sys.excepthook = lambda*args: sys.__excepthook__(*args)
>>> xxx
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/code.py", line 91, in runcode
exec(code, self.locals)
~~~~^^^^^^^^^^^^^^^^^^^
File "<python-input-2>", line 1, in <module>
xxx
NameError: name 'xxx' is not defined
changed the title [-]The new REPL outputs different tracebeck when custom sys.systemhook is used[/-][+]The new REPL outputs different tracebeck when custom sys.excepthook is used[/+]on Jul 31, 2024
sys.excepthook is of course called on purpose, but the traceback was not corrected for it. And sys.last_traceback was not always correct even with the default sys.excepthook.
Activity
serhiy-storchaka commentedon Jul 31, 2024
And for compile-time errors:
devdanzin commentedon Jul 31, 2024
Seems to be done on purpose in
code.InteractiveInterpreter.showsyntaxerror:cpython/Lib/code.py
Lines 126 to 132 in bd3d31f
I suppose this could be overridden in _pyrepl to always output with
.write()?pythongh-122478: Remove internal frames from tracebacks in REPL
[-]The new REPL outputs different tracebeck when custom sys.systemhook is used[/-][+]The new REPL outputs different tracebeck when custom sys.excepthook is used[/+]pythongh-122478: Remove internal frames from tracebacks in REPL
serhiy-storchaka commentedon Jul 31, 2024
sys.excepthookis of course called on purpose, but the traceback was not corrected for it. Andsys.last_tracebackwas not always correct even with the defaultsys.excepthook.gh-122478: Remove internal frames from tracebacks in REPL (GH-122528)
[3.12] pythongh-122478: Remove internal frames from tracebacks in REPL (
pythongh-122478: Remove internal frames from tracebacks in REPL (pyth…
pythongh-122478: Remove internal frames from tracebacks in REPL (pyth…
[3.13] pythongh-122478: Remove internal frames from tracebacks in REPL (
[3.13] pythongh-122478: Remove internal frames from tracebacks in REPL (
[3.13] gh-122478: Remove internal frames from tracebacks in REPL (GH-…
[3.12] gh-122478: Remove internal frames from tracebacks in REPL (GH-…
skirpichev commentedon Jan 21, 2025
@serhiy-storchaka, can this be closed?