mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
[3.13] gh-122546: use same filename for different exceptions in new repl (GH-123217) (#123226)
This commit is contained in:
parent
5148e03f0f
commit
5271f8fead
4 changed files with 14 additions and 11 deletions
11
Lib/code.py
11
Lib/code.py
|
@ -113,16 +113,7 @@ class InteractiveInterpreter:
|
|||
sys.last_value = value
|
||||
sys.last_traceback = tb
|
||||
if filename and type is SyntaxError:
|
||||
# Work hard to stuff the correct filename in the exception
|
||||
try:
|
||||
msg, (dummy_filename, lineno, offset, line) = value.args
|
||||
except ValueError:
|
||||
# Not the format we expect; leave it alone
|
||||
pass
|
||||
else:
|
||||
# Stuff in the right filename
|
||||
value = SyntaxError(msg, (filename, lineno, offset, line))
|
||||
sys.last_exc = sys.last_value = value
|
||||
value.filename = filename
|
||||
# Set the line of text that the exception refers to
|
||||
source = kwargs.pop('source', '')
|
||||
lines = source.splitlines()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue