mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-43017: Improve error message for unparenthesised tuples in comprehensions (GH24314)
This commit is contained in:
parent
4090151816
commit
835f14ff8e
5 changed files with 490 additions and 398 deletions
|
@ -235,6 +235,21 @@ SyntaxError: invalid syntax
|
|||
Traceback (most recent call last):
|
||||
SyntaxError: invalid syntax
|
||||
|
||||
Comprehensions creating tuples without parentheses
|
||||
should produce a specialized error message:
|
||||
|
||||
>>> [x,y for x,y in range(100)]
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: did you forget parentheses around the comprehension target?
|
||||
|
||||
>>> {x,y for x,y in range(100)}
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: did you forget parentheses around the comprehension target?
|
||||
|
||||
>>> {x,y: None for x,y in range(100)}
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: did you forget parentheses around the comprehension target?
|
||||
|
||||
From compiler_complex_args():
|
||||
|
||||
>>> def f(None=1):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue