*/
static string
-new_type_comment(const char *s, struct compiling *c)
+new_type_comment(const char *s)
{
return PyUnicode_DecodeUTF8(s, strlen(s), NULL);
}
-#define NEW_TYPE_COMMENT(n) new_type_comment(STR(n), c)
+#define NEW_TYPE_COMMENT(n) new_type_comment(STR(n))
static int
num_stmts(const node *n)
case TYPE_COMMENT:
/* arg will be equal to the last argument processed */
arg->type_comment = NEW_TYPE_COMMENT(ch);
+ if (!arg->type_comment)
+ goto error;
i += 1;
break;
case DOUBLESTAR:
if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) {
vararg->type_comment = NEW_TYPE_COMMENT(CHILD(n, i));
+ if (!vararg->type_comment)
+ return NULL;
i += 1;
}
/* arg will be equal to the last argument processed */
arg->type_comment = NEW_TYPE_COMMENT(ch);
+ if (!arg->type_comment)
+ return NULL;
i += 1;
break;
default:
}
if (TYPE(CHILD(n, name_i + 3)) == TYPE_COMMENT) {
type_comment = NEW_TYPE_COMMENT(CHILD(n, name_i + 3));
+ if (!type_comment)
+ return NULL;
name_i += 1;
}
body = ast_for_suite(c, CHILD(n, name_i + 3));
return NULL;
}
type_comment = NEW_TYPE_COMMENT(tc);
+ if (!type_comment)
+ return NULL;
}
}
expression = ast_for_expr(c, value);
if (!expression)
return NULL;
- if (has_type_comment)
+ if (has_type_comment) {
type_comment = NEW_TYPE_COMMENT(CHILD(n, nch_minus_type));
+ if (!type_comment)
+ return NULL;
+ }
else
type_comment = NULL;
return Assign(targets, expression, type_comment, LINENO(n), n->n_col_offset,
}
else {
i = 2;
- if (TYPE(CHILD(n, 1)) == TYPE_COMMENT)
+ if (TYPE(CHILD(n, 1)) == TYPE_COMMENT) {
i += 2;
+ REQ(CHILD(n, 2), NEWLINE);
+ }
for (; i < (NCH(n) - 1); i++) {
ch = CHILD(n, i);
get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);
}
- if (has_type_comment)
+ if (has_type_comment) {
type_comment = NEW_TYPE_COMMENT(CHILD(n, 5));
+ if (!type_comment)
+ return NULL;
+ }
else
type_comment = NULL;
return NULL;
get_last_end_pos(body, &end_lineno, &end_col_offset);
- if (has_type_comment)
+ if (has_type_comment) {
type_comment = NEW_TYPE_COMMENT(CHILD(n, NCH(n) - 2));
+ if (!type_comment)
+ return NULL;
+ }
else
type_comment = NULL;