]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-122546: Relax SyntaxError check when raising errors on the new REPL (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 23 Aug 2024 00:32:11 +0000 (02:32 +0200)
committerGitHub <noreply@github.com>
Fri, 23 Aug 2024 00:32:11 +0000 (00:32 +0000)
gh-122546: Relax SyntaxError check when raising errors on the new REPL (GH-123233)
(cherry picked from commit 4c3f0cbeaec0d49212d305618743fabb0e74a696)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Lib/code.py
Lib/test/test_pyrepl/test_pyrepl.py

index 5f7a2d3be07cad4a3dcca36a9882e7dddf5cfa5b..25f5b6a577fff815cdfce4e45371635ea3f86839 100644 (file)
@@ -110,7 +110,7 @@ class InteractiveInterpreter:
         colorize = kwargs.pop('colorize', False)
         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, colorize, source)
index a433212fe92ddc0e920547dc32d570d7781274c6..9944cd08dd516274366e33353aef4fe86efb2ac4 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)
 
     def run_repl(
         self,