gh-122546: Relax SyntaxError check when raising errors on the new REPL (#123233)

This commit is contained in:
Sergey B Kirpichev 2024-08-23 02:25:33 +03:00 committed by GitHub
parent 297f2e093e
commit 4c3f0cbeae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View 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)

View 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):