Kaydet (Commit) 5d1ff94b authored tarafından Benjamin Peterson's avatar Benjamin Peterson

set Print.values to NULL if there are no values

üst 0805b28f
...@@ -2144,9 +2144,9 @@ ast_for_print_stmt(struct compiling *c, const node *n) ...@@ -2144,9 +2144,9 @@ ast_for_print_stmt(struct compiling *c, const node *n)
| '>>' test [ (',' test)+ [','] ] ) | '>>' test [ (',' test)+ [','] ] )
*/ */
expr_ty dest = NULL, expression; expr_ty dest = NULL, expression;
asdl_seq *seq; asdl_seq *seq = NULL;
bool nl; bool nl;
int i, j, start = 1; int i, j, values_count, start = 1;
REQ(n, print_stmt); REQ(n, print_stmt);
if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) { if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) {
...@@ -2155,7 +2155,9 @@ ast_for_print_stmt(struct compiling *c, const node *n) ...@@ -2155,7 +2155,9 @@ ast_for_print_stmt(struct compiling *c, const node *n)
return NULL; return NULL;
start = 4; start = 4;
} }
seq = asdl_seq_new((NCH(n) + 1 - start) / 2, c->c_arena); values_count = (NCH(n) + 1 - start) / 2;
if (values_count) {
seq = asdl_seq_new(values_count, c->c_arena);
if (!seq) if (!seq)
return NULL; return NULL;
for (i = start, j = 0; i < NCH(n); i += 2, ++j) { for (i = start, j = 0; i < NCH(n); i += 2, ++j) {
...@@ -2164,6 +2166,7 @@ ast_for_print_stmt(struct compiling *c, const node *n) ...@@ -2164,6 +2166,7 @@ ast_for_print_stmt(struct compiling *c, const node *n)
return NULL; return NULL;
asdl_seq_SET(seq, j, expression); asdl_seq_SET(seq, j, expression);
} }
}
nl = (TYPE(CHILD(n, NCH(n) - 1)) == COMMA) ? false : true; nl = (TYPE(CHILD(n, NCH(n) - 1)) == COMMA) ? false : true;
return Print(dest, seq, nl, LINENO(n), n->n_col_offset, c->c_arena); return Print(dest, seq, nl, LINENO(n), n->n_col_offset, c->c_arena);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment