summaryrefslogtreecommitdiffstats
path: root/Python/Python-ast.c
diff options
context:
space:
mode:
authorSamuel <samuel@knutsen.co>2025-05-04 23:03:38 (GMT)
committerGitHub <noreply@github.com>2025-05-04 23:03:38 (GMT)
commit30840706b029645b9631b92c687834fcced6413e (patch)
tree62105298aada0abe663cf21269e5dc2b65903688 /Python/Python-ast.c
parentaf5799f3056b0eee61fc09587633500a3690e67e (diff)
downloadcpython-30840706b029645b9631b92c687834fcced6413e.zip
cpython-30840706b029645b9631b92c687834fcced6413e.tar.gz
cpython-30840706b029645b9631b92c687834fcced6413e.tar.bz2
gh-131421: fix ASDL grammar for `Dict` to have an `expr?*` keys field (#131419)
In the `ast` documentation for Python: * https://docs.python.org/3/library/ast.html#ast.Dict it is made clear that: > When doing dictionary unpacking using dictionary literals the expression to be expanded goes in the values list, with a `None` at the corresponding position in `keys`. Hence, `keys` is really a `expr?*` and *not* a `expr*`. Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r--Python/Python-ast.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 94d9a76..df03556 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -6362,7 +6362,7 @@ init_types(void *arg)
" | UnaryOp(unaryop op, expr operand)\n"
" | Lambda(arguments args, expr body)\n"
" | IfExp(expr test, expr body, expr orelse)\n"
- " | Dict(expr* keys, expr* values)\n"
+ " | Dict(expr?* keys, expr* values)\n"
" | Set(expr* elts)\n"
" | ListComp(expr elt, comprehension* generators)\n"
" | SetComp(expr elt, comprehension* generators)\n"
@@ -6419,7 +6419,7 @@ init_types(void *arg)
if (!state->IfExp_type) return -1;
state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
2,
- "Dict(expr* keys, expr* values)");
+ "Dict(expr?* keys, expr* values)");
if (!state->Dict_type) return -1;
state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
"Set(expr* elts)");