diff options
author | Matthew Rahtz <matthew.rahtz@gmail.com> | 2022-03-26 16:55:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-26 16:55:35 (GMT) |
commit | e8e737bcf6d22927caebc30c5d57ac4634063219 (patch) | |
tree | 6c0d4d51e8216f02fa0e6874aa4d78e20dd9397a /Python/compile.c | |
parent | 26cca8067bf5306e372c0e90036d832c5021fd90 (diff) | |
download | cpython-e8e737bcf6d22927caebc30c5d57ac4634063219.zip cpython-e8e737bcf6d22927caebc30c5d57ac4634063219.tar.gz cpython-e8e737bcf6d22927caebc30c5d57ac4634063219.tar.bz2 |
bpo-43224: Implement PEP 646 grammar changes (GH-31018)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index e24f425..06edcf1 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2335,10 +2335,20 @@ compiler_visit_argannotation(struct compiler *c, identifier id, Py_DECREF(mangled); if (c->c_future->ff_features & CO_FUTURE_ANNOTATIONS) { - VISIT(c, annexpr, annotation) + VISIT(c, annexpr, annotation); } else { - VISIT(c, expr, annotation); + if (annotation->kind == Starred_kind) { + // *args: *Ts (where Ts is a TypeVarTuple). + // Do [annotation_value] = [*Ts]. + // (Note that in theory we could end up here even for an argument + // other than *args, but in practice the grammar doesn't allow it.) + VISIT(c, expr, annotation->v.Starred.value); + ADDOP_I(c, UNPACK_SEQUENCE, (Py_ssize_t) 1); + } + else { + VISIT(c, expr, annotation); + } } *annotations_len += 2; return 1; |