bpo-44305: Improve syntax error for try blocks without except or finally (GH-26523)

This commit is contained in:
Pablo Galindo 2021-06-03 23:52:12 +01:00 committed by GitHub
parent 3446516ffa
commit b250f89bb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 554 additions and 440 deletions

View file

@ -882,6 +882,14 @@ leading to spurious errors.
Traceback (most recent call last):
SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='?
Custom error messages for try blocks that are not followed by except/finally
>>> try:
... x = 34
...
Traceback (most recent call last):
SyntaxError: expected 'except' or 'finally' block
Ensure that early = are not matched by the parser as invalid comparisons
>>> f(2, 4, x=34); 1 $ 2
Traceback (most recent call last):