diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-04-13 01:32:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-13 01:32:33 (GMT) |
commit | d9151cb45371836d39b6d53afb50c5bcd353c661 (patch) | |
tree | 2ea7c00ab4ededa92fb5405834c26d7e0c3c6c37 /Grammar | |
parent | c1a66bdd6f884e2ec813891c5c7e2b1ceeede8f1 (diff) | |
download | cpython-d9151cb45371836d39b6d53afb50c5bcd353c661.zip cpython-d9151cb45371836d39b6d53afb50c5bcd353c661.tar.gz cpython-d9151cb45371836d39b6d53afb50c5bcd353c661.tar.bz2 |
Ensure that early = are not matched by the parser as invalid comparisons (GH-25375)
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index 324793c..8524a12 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -447,6 +447,10 @@ named_expression[expr_ty]: | invalid_named_expression | expression !':=' +direct_named_expression[expr_ty]: + | a=NAME ':=' ~ b=expression { _PyAST_NamedExpr(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), b, EXTRA) } + | expression !':=' + annotated_rhs[expr_ty]: yield_expr | star_expressions expressions[expr_ty]: @@ -671,7 +675,7 @@ arguments[expr_ty] (memo): | a=args [','] &')' { a } | invalid_arguments args[expr_ty]: - | a[asdl_expr_seq*]=','.(starred_expression | named_expression !'=')+ b=[',' k=kwargs {k}] { _PyPegen_collect_call_seqs(p, a, b, EXTRA) } + | a[asdl_expr_seq*]=','.(starred_expression | direct_named_expression !'=')+ b=[',' k=kwargs {k}] { _PyPegen_collect_call_seqs(p, a, b, EXTRA) } | a=kwargs { _PyAST_Call(_PyPegen_dummy_name(p), CHECK_NULL_ALLOWED(asdl_expr_seq*, _PyPegen_seq_extract_starred_exprs(p, a)), CHECK_NULL_ALLOWED(asdl_keyword_seq*, _PyPegen_seq_delete_starred_exprs(p, a)), |