https://github.com/python/cpython/commit/4c3f0cbeaec0d49212d305618743fabb0e74a696
commit: 4c3f0cbeaec0d49212d305618743fabb0e74a696
branch: main
author: Sergey B Kirpichev <[email protected]>
committer: pablogsal <[email protected]>
date: 2024-08-23T00:25:33+01:00
summary:
gh-122546: Relax SyntaxError check when raising errors on the new REPL (#123233)
files:
M Lib/code.py
M Lib/test/test_pyrepl/test_pyrepl.py
diff --git a/Lib/code.py b/Lib/code.py
index c559191d8a747b..c7c59ee20219c5 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -108,7 +108,7 @@ def showsyntaxerror(self, filename=None, **kwargs):
"""
try:
typ, value, tb = sys.exc_info()
- if filename and typ is SyntaxError:
+ if filename and issubclass(typ, SyntaxError):
value.filename = filename
source = kwargs.pop('source', "")
self._showtraceback(typ, value, None, source)
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py
b/Lib/test/test_pyrepl/test_pyrepl.py
index 779849759225e5..b03cf136ec5c78 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -1109,6 +1109,10 @@ def test_correct_filename_in_syntaxerrors(self):
self.skipTest("pyrepl not available")
self.assertIn("SyntaxError: invalid syntax", output)
self.assertIn("<python-input-0>", output)
+ commands = " b\nexit()\n"
+ output, exit_code = self.run_repl(commands, env=env)
+ self.assertIn("IndentationError: unexpected indent", output)
+ self.assertIn("<python-input-0>", output)
@force_not_colorized
def test_proper_tracebacklimit(self):
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]