Skip to content

Commit

Permalink
gh-122546: Relax SyntaxError check when raising errors on the new REPL (
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev authored Aug 22, 2024
1 parent 297f2e0 commit 4c3f0cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def showsyntaxerror(self, filename=None, **kwargs):
"""
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)
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_pyrepl/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,10 @@ def test_correct_filename_in_syntaxerrors(self):
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):
Expand Down

0 comments on commit 4c3f0cb

Please sign in to comment.