diff --git a/CHANGES.md b/CHANGES.md index db519ac6bbc..94d1c69259a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ### _Black_ - Fixed Python 3.10 support on platforms without ProcessPoolExecutor (#2631) +- Fixed `match` statements with open sequence subjects, like `match a, b:` (#2639) ## 21.11b1 diff --git a/src/blib2to3/Grammar.txt b/src/blib2to3/Grammar.txt index c2a62543abb..de9a6a2283f 100644 --- a/src/blib2to3/Grammar.txt +++ b/src/blib2to3/Grammar.txt @@ -238,7 +238,7 @@ yield_arg: 'from' test | testlist_star_expr # to reformat them. match_stmt: "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT -subject_expr: namedexpr_test +subject_expr: namedexpr_test (',' namedexpr_test)* [','] # cases case_block: "case" patterns [guard] ':' suite diff --git a/tests/data/pattern_matching_extras.py b/tests/data/pattern_matching_extras.py index 614e66aebe6..d4bba38ee7c 100644 --- a/tests/data/pattern_matching_extras.py +++ b/tests/data/pattern_matching_extras.py @@ -27,3 +27,19 @@ def func(match: case, case: match) -> case: ... case func(match, case): ... + + +match maybe, multiple: + case perhaps, 5: + pass + case perhaps, 6,: + pass + + +match more := (than, one), indeed,: + case _, (5, 6): + pass + case [[5], (6)], [7],: + pass + case _: + pass