mirror of
https://github.com/python/cpython.git
synced 2026-03-06 04:50:58 +00:00
[3.12] gh-109114: Relax the check for invalid lambdas inside f-strings to avoid false positives (GH-109121). (#109155)
(cherry picked from commit 5bda2f637e)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
parent
8208657f3d
commit
21f4e6d6cb
4 changed files with 1697 additions and 1749 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue