bpo-43224: Implement PEP 646 grammar changes (GH-31018)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Matthew Rahtz 2022-03-26 16:55:35 +00:00 committed by GitHub
parent 26cca8067b
commit e8e737bcf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 4324 additions and 3396 deletions

View file

@ -786,19 +786,8 @@ static int
append_ast_subscript(_PyUnicodeWriter *writer, expr_ty e)
{
APPEND_EXPR(e->v.Subscript.value, PR_ATOM);
int level = PR_TUPLE;
expr_ty slice = e->v.Subscript.slice;
if (slice->kind == Tuple_kind) {
for (Py_ssize_t i = 0; i < asdl_seq_LEN(slice->v.Tuple.elts); i++) {
expr_ty element = asdl_seq_GET(slice->v.Tuple.elts, i);
if (element->kind == Starred_kind) {
++level;
break;
}
}
}
APPEND_STR("[");
APPEND_EXPR(e->v.Subscript.slice, level);
APPEND_EXPR(e->v.Subscript.slice, PR_TUPLE);
APPEND_STR_FINISH("]");
}