From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 23 Aug 2024 00:32:11 +0000 (+0200) Subject: [3.13] gh-122546: Relax SyntaxError check when raising errors on the new REPL (GH... X-Git-Tag: v3.13.0rc2~113 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fda8aec625d5be02ebb1c67fad89db85fa1f4f12;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-122546: Relax SyntaxError check when raising errors on the new REPL (GH-123233) (#123247) 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 --- diff --git a/Lib/code.py b/Lib/code.py index 5f7a2d3be07c..25f5b6a577ff 100644 --- a/Lib/code.py +++ b/Lib/code.py @@ -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) diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index a433212fe92d..9944cd08dd51 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) def run_repl( self,