8000 compiler_stmt_expr, compiler_async_for return SUCCESS/ERROR · python/cpython@f8b658e · GitHub
[go: up one dir, main page]

Skip to content

Commit f8b658e

Browse files
committed
compiler_stmt_expr, compiler_async_for return SUCCESS/ERROR
1 parent 229d6fd commit f8b658e

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

Python/compile.c

Lines changed: 27 additions & 27 deletions
< 8000 td data-grid-cell-id="diff-ebc983d9f91e5bcf73500e377ac65e85863c4f77fd5b6b6caf4fcdf7c0f0b057-3323-3322-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionNum-bgColor, var(--diffBlob-deletion-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">3323
Original file line numberDiff line numberDiff line change
@@ -3305,32 +3305,32 @@ compiler_async_for(struct compiler *c, stmt_ty s)
33053305
if (IS_TOP_LEVEL_AWAIT(c)){
33063306
c->u->u_ste->ste_coroutine = 1;
33073307
} else if (c->u->u_scope_type != COMPILER_SCOPE_ASYNC_FUNCTION) {
3308-
return compiler_error(c, loc, "'async for' outside async function");
3308+
compiler_error(c, loc, "'async for' outside async function");
3309+
return ERROR;
33093310
}
33103311

33113312
NEW_JUMP_TARGET_LABEL(c, start);
33123313
NEW_JUMP_TARGET_LABEL(c, except);
33133314
NEW_JUMP_TARGET_LABEL(c, end);
33143315

3315-
_VISIT(c, expr, s->v.AsyncFor.iter);
3316-
_ADDOP(c, loc, GET_AITER);
3316+
VISIT(c, expr, s->v.AsyncFor.iter);
3317+
ADDOP(c, loc, GET_AITER);
33173318

33183319
USE_LABEL(c, start);
3319-
if (compiler_push_fblock(c, loc, FOR_LOOP, start, end, NULL) < 0) {
3320-
return 0;
3321-
}
3320+
RETURN_IF_ERROR(compiler_push_fblock(c, loc, FOR_LOOP, start, end, NULL));
3321+
33223322
/* SETUP_FINALLY to guard the __anext__ call */
-
_ADDOP_JUMP(c, loc, SETUP_FINALLY, except);
3324-
_ADDOP(c, loc, GET_ANEXT);
3325-
_ADDOP_LOAD_CONST(c, loc, Py_None);
3326-
_ADD_YIELD_FROM(c, loc, 1);
3327-
_ADDOP(c, loc, POP_BLOCK); /* for SETUP_FINALLY */
3323+
ADDOP_JUMP(c, loc, SETUP_FINALLY, except);
3324+
ADDOP(c, loc, GET_ANEXT);
3325+
ADDOP_LOAD_CONST(c, loc, Py_None);
3326+
ADD_YIELD_FROM(c, loc, 1);
3327+
ADDOP(c, loc, POP_BLOCK); /* for SETUP_FINALLY */
33283328

33293329
/* Success block for __anext__ */
3330-
_VISIT(c, expr, s->v.AsyncFor.target);
3331-
_VISIT_SEQ(c, stmt, s->v.AsyncFor.body);
3330+
VISIT(c, expr, s->v.AsyncFor.target);
3331+
VISIT_SEQ(c, stmt, s->v.AsyncFor.body);
33323332
/* Mark jump as artificial */
3333-
_ADDOP_JUMP(c, NO_LOCATION, JUMP, start);
3333+
ADDOP_JUMP(c, NO_LOCATION, JUMP, start);
33343334

33353335
compiler_pop_fblock(c, FOR_LOOP, start);
33363336

@@ -3340,13 +3340,13 @@ compiler_async_for(struct compiler *c, stmt_ty s)
33403340
/* Use same line number as the iterator,
33413341
* as the END_ASYNC_FOR succeeds the `for`, not the body. */
33423342
loc = LOC(s->v.AsyncFor.iter);
3343-
_ADDOP(c, loc, END_ASYNC_FOR);
3343+
ADDOP(c, loc, END_ASYNC_FOR);
33443344

33453345
/* `else` block */
3346-
_VISIT_SEQ(c, stmt, s->v.For.orelse);
3346+
VISIT_SEQ(c, stmt, s->v.For.orelse);
33473347

33483348
USE_LABEL(c, end);
3349-
return 1;
3349+
return SUCCESS;
33503350
}
33513351

33523352
static int
@@ -4177,20 +4177,20 @@ static int
41774177
compiler_stmt_expr(struct compiler *c, location loc, expr_ty value)
41784178
{
41794179
if (c->c_interactive && c->c_nestlevel <= 1) {
4180-
_VISIT(c, expr, value);
4181-
_ADDOP(c, loc, PRINT_EXPR);
4182-
return 1;
4180+
VISIT(c, expr, value);
4181+
ADDOP(c, loc, PRINT_EXPR);
4182+
return SUCCESS;
41834183
}
41844184

41854185
if (value->kind == Constant_kind) {
41864186
/* ignore constant statement */
4187-
_ADDOP(c, loc, NOP);
4188-
return 1;
4187+
ADDOP(c, loc, NOP);
4188+
return SUCCESS;
41894189
}
41904190

4191-
_VISIT(c, expr, value);
4192-
_ADDOP(c, NO_LOCATION, POP_TOP); /* artificial */
4193-
return 1;
4191+
VISIT(c, expr, value);
4192+
ADDOP(c, NO_LOCATION, POP_TOP); /* artificial */
4193+
return SUCCESS;
41944194
}
41954195

41964196
static int
@@ -4261,7 +4261,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
42614261
break;
42624262
case Expr_kind:
42634263
{
4264-
return compiler_stmt_expr(c, LOC(s), s->v.Expr.value);
4264+
return compiler_stmt_expr(c, LOC(s), s->v.Expr.value) == SUCCESS ? 1 : 0;
42654265
}
42664266
case Pass_kind:
42674267
{
@@ -4283,7 +4283,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
42834283
case AsyncWith_kind:
42844284
return compiler_async_with(c, s, 0) == SUCCESS ? 1 : 0;
42854285
case AsyncFor_kind:
4286-
return compiler_async_for(c, s);
4286+
return compiler_async_for(c, s) == SUCCESS ? 1 : 0;
42874287
}
42884288

42894289
return 1;

0 commit comments

Comments
 (0)
0