summaryrefslogtreecommitdiffstats
path: root/Lib/code.py
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-08-22 23:28:09 (GMT)
committerGitHub <noreply@github.com>2024-08-22 23:28:09 (GMT)
commit5271f8feadc198407449514348c34e3fe77de448 (patch)
tree614c3b2f24c16915f09973689146fb5d4a2ff937 /Lib/code.py
parent5148e03f0f0aa4d2ffabf5df120e359f694d87a5 (diff)
downloadcpython-5271f8feadc198407449514348c34e3fe77de448.zip
cpython-5271f8feadc198407449514348c34e3fe77de448.tar.gz
cpython-5271f8feadc198407449514348c34e3fe77de448.tar.bz2
[3.13] gh-122546: use same filename for different exceptions in new repl (GH-123217) (#123226)
Diffstat (limited to 'Lib/code.py')
-rw-r--r--Lib/code.py11
1 files changed, 1 insertions, 10 deletions
diff --git a/Lib/code.py b/Lib/code.py
index aec7d61..ccf2d9d 100644
--- a/Lib/code.py
+++ b/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()