diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2023-09-08 17:00:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 17:00:23 (GMT) |
commit | 5bda2f637e1cfbca45a83aa6e22db25498064b27 (patch) | |
tree | 519a5adc00805065efc154ef7d65520880ca4769 /Grammar | |
parent | 87a7faf6b68c8076e640a9a1347a255f132d8382 (diff) | |
download | cpython-5bda2f637e1cfbca45a83aa6e22db25498064b27.zip cpython-5bda2f637e1cfbca45a83aa6e22db25498064b27.tar.gz cpython-5bda2f637e1cfbca45a83aa6e22db25498064b27.tar.bz2 |
gh-109114: Relax the check for invalid lambdas inside f-strings to avoid false positives (#109121)
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index e7c8178..ae998f9 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -1170,7 +1170,7 @@ invalid_expression: _PyPegen_check_legacy_stmt(p, a) ? NULL : p->tokens[p->mark-1]->level == 0 ? NULL : RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") } | a=disjunction 'if' b=disjunction !('else'|':') { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected 'else' after 'if' expression") } - | a='lambda' [lambda_params] b=':' &(FSTRING_MIDDLE | fstring_replacement_field) { + | a='lambda' [lambda_params] b=':' &FSTRING_MIDDLE { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "f-string: lambda expressions are not allowed without parentheses") } invalid_named_expression(memo): |