From: Sergey B Kirpichev Date: Thu, 22 Aug 2024 23:25:33 +0000 (+0300) Subject: gh-122546: Relax SyntaxError check when raising errors on the new REPL (#123233) X-Git-Tag: v3.14.0a1~718 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4c3f0cbeaec0d49212d305618743fabb0e74a696;p=thirdparty%2FPython%2Fcpython.git gh-122546: Relax SyntaxError check when raising errors on the new REPL (#123233) --- diff --git a/Lib/code.py b/Lib/code.py index c559191d8a74..c7c59ee20219 100644 --- a/Lib/code.py +++ b/Lib/code.py @@ -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) diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 779849759225..b03cf136ec5c 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -1109,6 +1109,10 @@ class TestMain(TestCase): self.skipTest("pyrepl not available") self.assertIn("SyntaxError: invalid syntax", output) self.assertIn("", output) + commands = " b\nexit()\n" + output, exit_code = self.run_repl(commands, env=env) + self.assertIn("IndentationError: unexpected indent", output) + self.assertIn("", output) @force_not_colorized def test_proper_tracebacklimit(self):