Handle more memory allocation failures without crashing.
diff --git a/Python/ast.c b/Python/ast.c
index d00fcc8..9180fd0 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -638,8 +638,10 @@
anything other than EQUAL or a comma? */
/* XXX Should NCH(n) check be made a separate check? */
if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
- asdl_seq_SET(defaults, j++,
- ast_for_expr(c, CHILD(n, i + 2)));
+ expr_ty expression = ast_for_expr(c, CHILD(n, i + 2));
+ if (!expression)
+ goto error;
+ asdl_seq_SET(defaults, j++, expression);
i += 2;
found_default = 1;
}