mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-40334: Produce better error messages for non-parenthesized genexps (GH-20153)
The error message, generated for a non-parenthesized generator expression in function calls, was still the generic `invalid syntax`, when the generator expression wasn't appearing as the first argument in the call. With this patch, even on input like `f(a, b, c for c in d, e)`, the correct error message gets produced.
This commit is contained in:
parent
7864f11cdf
commit
ae14583302
5 changed files with 79 additions and 6 deletions
|
@ -216,11 +216,9 @@ SyntaxError: Generator expression must be parenthesized
|
|||
>>> f(x for x in L, **{})
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Generator expression must be parenthesized
|
||||
|
||||
# >>> f(L, x for x in L)
|
||||
# Traceback (most recent call last):
|
||||
# SyntaxError: Generator expression must be parenthesized
|
||||
|
||||
>>> f(L, x for x in L)
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Generator expression must be parenthesized
|
||||
>>> f(x for x in L, y for y in L)
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: Generator expression must be parenthesized
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue