gh-119555: catch SyntaxError from compile() in the InteractiveColored… · python/cpython@86d1a1a · GitHub
Skip to content

Commit 86d1a1a

Browse files
authored
gh-119555: catch SyntaxError from compile() in the InteractiveColoredConsole (#119557)
1 parent c0faade commit 86d1a1a

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lib/_pyrepl/simple_interact.py

Lines changed: 1 addition & 1 deletion

Lib/test/test_pyrepl/test_interact.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ def test_runsource_shows_syntax_error_for_failed_compilation(self):
9494
with patch.object(console, "showsyntaxerror") as mock_showsyntaxerror:
9595
console.runsource(source)
9696
mock_showsyntaxerror.assert_called_once()
97+
source = dedent("""\
98+
match 1:
99+
case {0: _, 0j: _}:
100+
pass
101+
""")
102+
with patch.object(console, "showsyntaxerror") as mock_showsyntaxerror:
103+
console.runsource(source)
104+
mock_showsyntaxerror.assert_called_once()
97105

98106
def test_no_active_future(self):
99107
console = InteractiveColoredConsole()
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)