Skip to content

Commit

Permalink
pythongh-122546: Relax SyntaxError check when raising errors on the n…
Browse files Browse the repository at this point in the history
…ew REPL (pythonGH-123233)

(cherry picked from commit 4c3f0cb)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
  • Loading branch information
skirpichev authored and miss-islington committed Aug 23, 2024
1 parent 30eee22 commit b9e2f89
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 @@ -110,7 +110,7 @@ def showsyntaxerror(self, filename=None, **kwargs):
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)
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)

def run_repl(
self,
Expand Down

0 comments on commit b9e2f89

Please sign in to comment.