bpo-44456: Improve the syntax error when mixing keyword and positional patterns (GH-26793)

(cherry picked from commit 0acc258fe6)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-06-24 08:34:28 -07:00 committed by GitHub
parent b3fac2926b
commit 11f1a30cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 843 additions and 635 deletions

View file

@ -1240,6 +1240,30 @@ Corner-cases that used to crash:
... ...
Traceback (most recent call last):
SyntaxError: invalid pattern target
>>> match ...:
... case Foo(z=1, y=2, x):
... ...
Traceback (most recent call last):
SyntaxError: positional patterns follow keyword patterns
>>> match ...:
... case Foo(a, z=1, y=2, x):
... ...
Traceback (most recent call last):
SyntaxError: positional patterns follow keyword patterns
>>> match ...:
... case Foo(z=1, x, y=2):
... ...
Traceback (most recent call last):
SyntaxError: positional patterns follow keyword patterns
>>> match ...:
... case C(a=b, c, d=e, f, g=h, i, j=k, ...):
... ...
Traceback (most recent call last):
SyntaxError: positional patterns follow keyword patterns
"""
import re