]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-122546: Relax SyntaxError check when raising errors on the new REPL (#123233)
authorSergey B Kirpichev <skirpichev@gmail.com>
Thu, 22 Aug 2024 23:25:33 +0000 (02:25 +0300)
committerGitHub <noreply@github.com>
Thu, 22 Aug 2024 23:25:33 +0000 (00:25 +0100)
Lib/code.py
Lib/test/test_pyrepl/test_pyrepl.py

index c559191d8a747bcbb7d6a9a1f0ee9ddf0efcf45f..c7c59ee20219c513e888f8d746204750b405b38a 100644 (file)
@@ -108,7 +108,7 @@ class InteractiveInterpreter:
         """
         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)
index 779849759225e5bb726f63b00132cb1748103b12..b03cf136ec5c782961c23932e90f14149981c3f6 100644 (file)
@@ -1109,6 +1109,10 @@ class TestMain(TestCase):
             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):