Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21c09d9

Browse files
authored
Test syntax error on comma-less tuple-style sequence patterns (#115485)
Adds a test that length-1 tuple-style sequence patterns must end in a comma, since there isn't currently one. Spotted while reviewing Cython's proposed implementation of the pattern matching syntax (cython/cython#4897 (comment)) where there was a bug my the reimplementation that wasn't caught against the CPython tests here.
1 parent fc7e1aa commit 21c09d9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/test_patma.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,14 @@ def test_invalid_syntax_3(self):
29572957
pass
29582958
""")
29592959

2960+
def test_len1_tuple_sequence_pattern_comma(self):
2961+
# correct syntax would be `case(*x,):`
2962+
self.assert_syntax_error("""
2963+
match ...:
2964+
case (*x):
2965+
pass
2966+
""")
2967+
29602968
def test_mapping_pattern_keys_may_only_match_literals_and_attribute_lookups(self):
29612969
self.assert_syntax_error("""
29622970
match ...:

0 commit comments

Comments
 (0)