mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-43822: Improve syntax errors for missing commas (GH-25377)
This commit is contained in:
parent
e692f55979
commit
b280248be8
13 changed files with 1235 additions and 1034 deletions
|
@ -248,22 +248,36 @@ SyntaxError: did you forget parentheses around the comprehension target?
|
|||
|
||||
# Missing commas in literals collections should not
|
||||
# produce special error messages regarding missing
|
||||
# parentheses
|
||||
# parentheses, but about missing commas instead
|
||||
|
||||
>>> [1, 2 3]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
SyntaxError: invalid syntax. Perhaps you forgot a comma?
|
||||
|
||||
>>> {1, 2 3}
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
SyntaxError: invalid syntax. Perhaps you forgot a comma?
|
||||
|
||||
>>> {1:2, 2:5 3:12}
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
SyntaxError: invalid syntax. Perhaps you forgot a comma?
|
||||
|
||||
>>> (1, 2 3)
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax. Perhaps you forgot a comma?
|
||||
|
||||
# Make sure soft keywords constructs don't raise specialized
|
||||
# errors regarding missing commas
|
||||
|
||||
>>> match x:
|
||||
... y = 3
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
>>> match x:
|
||||
... case y:
|
||||
... 3 $ 3
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
From compiler_complex_args():
|
||||
|
@ -864,7 +878,7 @@ leading to spurious errors.
|
|||
SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='?
|
||||
|
||||
Ensure that early = are not matched by the parser as invalid comparisons
|
||||
>>> f(2, 4, x=34); {1,2 a}
|
||||
>>> f(2, 4, x=34); 1 $ 2
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue