mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-109114: Relax the check for invalid lambdas inside f-strings to avoid false positives (#109121)
This commit is contained in:
parent
87a7faf6b6
commit
5bda2f637e
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