]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-40334: Produce better error messages for non-parenthesized genexps (GH-20153)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 22 May 2020 01:14:55 +0000 (18:14 -0700)
committerGitHub <noreply@github.com>
Fri, 22 May 2020 01:14:55 +0000 (18:14 -0700)
commit55c89235247d9dbe8a4463c9c64edc7e48826a44
treefca57eb9f5e6214769255f0dd314dc68a7dc408f
parentb4d08f1eb53132af86b5da4286c97bd5b7851166
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.
(cherry picked from commit ae145833025b0156ee2a28219e3370f3b27b2a36)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Grammar/python.gram
Lib/test/test_syntax.py
Parser/pegen/parse.c
Parser/pegen/pegen.c
Parser/pegen/pegen.h