bpo-42128: Add 'missing :' syntax error message to match statements (GH-24733)
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 47df057..24233b2 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -825,6 +825,24 @@
Traceback (most recent call last):
SyntaxError: expected ':'
+ >>> match x
+ ... case list():
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: expected ':'
+
+ >>> match x:
+ ... case list()
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: expected ':'
+
+ >>> match x:
+ ... case [y] if y > 0
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: expected ':'
+
Make sure that the old "raise X, Y[, Z]" form is gone:
>>> raise X, Y
Traceback (most recent call last):
@@ -1159,6 +1177,24 @@ def test_error_parenthesis(self):
for paren in ")]}":
self._check_error(paren + "1 + 2", f"unmatched '\\{paren}'")
+ def test_match_call_does_not_raise_syntax_error(self):
+ code = """
+def match(x):
+ return 1+1
+
+match(34)
+"""
+ compile(code, "<string>", "exec")
+
+ def test_case_call_does_not_raise_syntax_error(self):
+ code = """
+def case(x):
+ return 1+1
+
+case(34)
+"""
+ compile(code, "<string>", "exec")
+
def test_main():
support.run_unittest(SyntaxTestCase)