mirror of
https://github.com/python/cpython.git
synced 2025-07-31 07:04:42 +00:00
[3.10] bpo-44305: Improve syntax error for try blocks without except or finally (GH-26523) (GH-26524)
(cherry picked from commit b250f89bb7
)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
3283bf4519
commit
e53f72a1b4
5 changed files with 554 additions and 440 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue