bpo-43017: Improve error message for unparenthesised tuples in comprehensions (GH24314)

This commit is contained in:
Pablo Galindo 2021-01-31 22:52:56 +00:00 committed by GitHub
parent 4090151816
commit 835f14ff8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 490 additions and 398 deletions

View file

@ -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):