mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-122546: use same filename for different exceptions in new repl (#123217)
* gh-122546: use same filename for different exceptions in new repl * +1
This commit is contained in:
parent
427b106162
commit
3d7b1a526d
4 changed files with 14 additions and 10 deletions
10
Lib/code.py
10
Lib/code.py
|
@ -109,15 +109,7 @@ class InteractiveInterpreter:
|
|||
try:
|
||||
typ, value, tb = sys.exc_info()
|
||||
if filename and typ 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))
|
||||
value.filename = filename
|
||||
source = kwargs.pop('source', "")
|
||||
self._showtraceback(typ, value, None, source)
|
||||
finally:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue