diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2020-11-17 01:17:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 01:17:12 (GMT) |
commit | b0aba1fcdc3da952698d99aec2334faa79a8b68c (patch) | |
tree | 7a349807a405f2adf73bd64b766715d543c22b81 /Grammar/python.gram | |
parent | a57b3d30f66c90f42da751bf82256b9b22961ed0 (diff) | |
download | cpython-b0aba1fcdc3da952698d99aec2334faa79a8b68c.zip cpython-b0aba1fcdc3da952698d99aec2334faa79a8b68c.tar.gz cpython-b0aba1fcdc3da952698d99aec2334faa79a8b68c.tar.bz2 |
bpo-42381: Allow walrus in set literals and set comprehensions (GH-23332)
Currently walruses are not allowerd in set literals and set comprehensions:
>>> {y := 4, 4**2, 3**3}
File "<stdin>", line 1
{y := 4, 4**2, 3**3}
^
SyntaxError: invalid syntax
but they should be allowed as well per PEP 572
Diffstat (limited to 'Grammar/python.gram')
-rw-r--r-- | Grammar/python.gram | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index a0e9a89..9e915ac 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -311,7 +311,6 @@ block[asdl_stmt_seq*] (memo): | simple_stmt | invalid_block -expressions_list[asdl_expr_seq*]: a[asdl_expr_seq*]=','.star_expression+ [','] { a } star_expressions[expr_ty]: | a=star_expression b=(',' c=star_expression { c })+ [','] { _Py_Tuple(CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, a, b)), Load, EXTRA) } @@ -519,9 +518,9 @@ group[expr_ty]: genexp[expr_ty]: | '(' a=named_expression ~ b=for_if_clauses ')' { _Py_GeneratorExp(a, b, EXTRA) } | invalid_comprehension -set[expr_ty]: '{' a=expressions_list '}' { _Py_Set(a, EXTRA) } +set[expr_ty]: '{' a=star_named_expressions '}' { _Py_Set(a, EXTRA) } setcomp[expr_ty]: - | '{' a=expression ~ b=for_if_clauses '}' { _Py_SetComp(a, b, EXTRA) } + | '{' a=named_expression ~ b=for_if_clauses '}' { _Py_SetComp(a, b, EXTRA) } | invalid_comprehension dict[expr_ty]: | '{' a=[double_starred_kvpairs] '}' { |