gh-133999: Fix except parsing regression in 3.14 (#134035)

This commit is contained in:
sobolevn 2025-05-17 17:57:02 +03:00 committed by GitHub
parent 7a9d46295a
commit 84914ad0e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 12 deletions

View file

@ -1431,6 +1431,23 @@ Better error message for using `except as` with not a name:
Traceback (most recent call last):
SyntaxError: cannot use except* statement with literal
Regression tests for gh-133999:
>>> try: pass
... except TypeError as name: raise from None
Traceback (most recent call last):
SyntaxError: invalid syntax
>>> try: pass
... except* TypeError as name: raise from None
Traceback (most recent call last):
SyntaxError: invalid syntax
>>> match 1:
... case 1 | 2 as abc: raise from None
Traceback (most recent call last):
SyntaxError: invalid syntax
Ensure that early = are not matched by the parser as invalid comparisons
>>> f(2, 4, x=34); 1 $ 2
Traceback (most recent call last):