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

This commit is contained in:
Pablo Galindo 2021-06-24 16:09:57 +01:00 committed by GitHub
parent b19f455339
commit 0acc258fe6
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