Skip to content

Commit fda8aec

Browse files
[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 4c3f0cb) Co-authored-by: Sergey B Kirpichev <[email protected]>
1 parent 30eee22 commit fda8aec

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
@@ -110,7 +110,7 @@ def showsyntaxerror(self, filename=None, **kwargs):
110110
colorize = kwargs.pop('colorize', False)
111111
try:
112112
typ, value, tb = sys.exc_info()
113-
if filename and typ is SyntaxError:
113+
if filename and issubclass(typ, SyntaxError):
114114
value.filename = filename
115115
source = kwargs.pop('source', "")
116116
self._showtraceback(typ, value, None, colorize, 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
def run_repl(
11141118
self,

0 commit comments

Comments
 (0)