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:
Lysandros Nikolaou 2020-05-22 03:56:52 +03:00 committed by GitHub
parent 7864f11cdf
commit ae14583302
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 6 deletions

View file

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