Add tests for r84209 (crashes in the Ast builder)
Also remove one tab, and move a check closer to the possible failure.
diff --git a/Python/ast.c b/Python/ast.c
index 6ea830b..9f6b7ea 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -689,7 +689,7 @@
if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
expression = ast_for_expr(c, CHILD(n, i + 2));
if (!expression)
- goto error;
+ goto error;
asdl_seq_SET(kwdefaults, j, expression);
i += 2; /* '=' and test */
}
@@ -892,14 +892,14 @@
ch = CHILD(n, i+1); /* tfpdef */
assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef);
kwarg = NEW_IDENTIFIER(CHILD(ch, 0));
+ if (!kwarg)
+ return NULL;
if (NCH(ch) > 1) {
/* there is an annotation on the kwarg */
kwargannotation = ast_for_expr(c, CHILD(ch, 2));
if (!kwargannotation)
return NULL;
}
- if (!kwarg)
- return NULL;
if (forbidden_name(kwarg, CHILD(ch, 0), 0))
return NULL;
i += 3;