Skip to content

Commit 4c3f0cb

Browse files
authored
gh-122546: Relax SyntaxError check when raising errors on the new REPL (#123233)
1 parent 297f2e0 commit 4c3f0cb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def showsyntaxerror(self, filename=None, **kwargs):
108108
"""
109109
try:
110110
typ, value, tb = sys.exc_info()
111-
if filename and typ is SyntaxError:
111+
if filename and issubclass(typ, SyntaxError):
112112
value.filename = filename
113113
source = kwargs.pop('source', "")
114114
self._showtraceback(typ, value, None, source)

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,10 @@ def test_correct_filename_in_syntaxerrors(self):
11091109
self.skipTest("pyrepl not available")
11101110
self.assertIn("SyntaxError: invalid syntax", output)
11111111
self.assertIn("<python-input-0>", output)
1112+
commands = " b\nexit()\n"
1113+
output, exit_code = self.run_repl(commands, env=env)
1114+
self.assertIn("IndentationError: unexpected indent", output)
1115+
self.assertIn("<python-input-0>", output)
11121116

11131117
@force_not_colorized
11141118
def test_proper_tracebacklimit(self):

0 commit comments

Comments
 (0)