}
for (Py_ssize_t i = 0; i < len; i++) {
expr_ty e = asdl_seq_GET(seq, i);
- asdl_seq_SET(new_seq, i, _PyPegen_set_expr_context(p, e, ctx));
+ expr_ty new_e = _PyPegen_set_expr_context(p, e, ctx);
+ if (!new_e) {
+ return NULL;
+ }
+ asdl_seq_SET(new_seq, i, new_e);
}
return new_seq;
}
static expr_ty
_set_tuple_context(Parser *p, expr_ty e, expr_context_ty ctx)
{
- return _PyAST_Tuple(
- _set_seq_context(p, e->v.Tuple.elts, ctx),
- ctx,
- EXTRA_EXPR(e, e));
+ asdl_expr_seq *seq = _set_seq_context(p, e->v.Tuple.elts, ctx);
+ if (!seq && PyErr_Occurred()) {
+ return NULL;
+ }
+ return _PyAST_Tuple(seq, ctx, EXTRA_EXPR(e, e));
}
static expr_ty
_set_list_context(Parser *p, expr_ty e, expr_context_ty ctx)
{
- return _PyAST_List(
- _set_seq_context(p, e->v.List.elts, ctx),
- ctx,
- EXTRA_EXPR(e, e));
+ asdl_expr_seq *seq = _set_seq_context(p, e->v.List.elts, ctx);
+ if (!seq && PyErr_Occurred()) {
+ return NULL;
+ }
+ return _PyAST_List(seq, ctx, EXTRA_EXPR(e, e));
}
static expr_ty
static expr_ty
_set_starred_context(Parser *p, expr_ty e, expr_context_ty ctx)
{
- return _PyAST_Starred(_PyPegen_set_expr_context(p, e->v.Starred.value, ctx),
- ctx, EXTRA_EXPR(e, e));
+ expr_ty inner = _PyPegen_set_expr_context(p, e->v.Starred.value, ctx);
+ if (!inner) {
+ return NULL;
+ }
+ return _PyAST_Starred(inner, ctx, EXTRA_EXPR(e, e));
}
/* Creates an `expr_ty` equivalent to `expr` but with `ctx` as context */
}
asdl_expr_seq *starreds = _PyPegen_seq_extract_starred_exprs(p, b);
+ if (!starreds && PyErr_Occurred()) {
+ return NULL;
+ }
+
asdl_keyword_seq *keywords = _PyPegen_seq_delete_starred_exprs(p, b);
+ if (!keywords && PyErr_Occurred()) {
+ return NULL;
+ }
if (starreds) {
total_len += asdl_seq_LEN(starreds);
end_col_offset, arena
);
- if (!debug) {
+ if (!interpolation || !debug) {
return interpolation;
}
}
asdl_expr_seq *values = _Py_asdl_expr_seq_new(2, arena);
+ if (!values) {
+ return NULL;
+ }
asdl_seq_SET(values, 0, debug_text);
asdl_seq_SET(values, 1, interpolation);
return _PyAST_JoinedStr(values, lineno, col_offset, debug_end_line, debug_end_offset, p->arena);
end_col_offset, arena
);
- if (!debug) {
+ if (!formatted_value || !debug) {
return formatted_value;
}
}
asdl_expr_seq *values = _Py_asdl_expr_seq_new(2, arena);
+ if (!values) {
+ return NULL;
+ }
asdl_seq_SET(values, 0, debug_text);
asdl_seq_SET(values, 1, formatted_value);
return _PyAST_JoinedStr(values, lineno, col_offset, debug_end_line, debug_end_offset, p->arena);
{
asdl_expr_seq *values = _build_concatenated_str(p, strings, lineno,
col_offset, end_lineno, end_col_offset, arena);
+ if (!values) {
+ return NULL;
+ }
return _PyAST_JoinedStr(values, lineno, col_offset, end_lineno, end_col_offset, p->arena);
}
{
asdl_expr_seq *values = _build_concatenated_str(p, strings, lineno,
col_offset, end_lineno, end_col_offset, arena);
+ if (!values) {
+ return NULL;
+ }
return _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
end_col_offset, arena);
}