8000 compiler_return returns SUCCESS/ERROR · python/cpython@d1a28e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit d1a28e4

Browse files
committed
compiler_return returns SUCCESS/ERROR
1 parent 1409c3e commit d1a28e4

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

Python/compile.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,41 +3389,41 @@ compiler_return(struct compiler *c, stmt_ty s)
33893389
location loc = LOC(s);
33903390
int preserve_tos = ((s->v.Return.value != NULL) &&
33913391
(s->v.Return.value->kind != Constant_kind));
3392-
if (c->u->u_ste->ste_type != FunctionBlock)
3393-
return compiler_error(c, loc, "'return' outside function");
3392+
if (c->u->u_ste->ste_type != FunctionBlock) {
3393+
compiler_error(c, loc, "'return' outside function");
3394+
return ERROR;
3395+
}
33943396
if (s->v.Return.value != NULL &&
33953397
c->u->u_ste->ste_coroutine && c->u->u_ste->ste_generator)
33963398
{
3397-
return compiler_error(
3398-
c, loc, "'return' with value in async generator");
3399+
compiler_error(c, loc, "'return' with value in async generator");
3400+
return ERROR;
33993401
}
34003402

34013403
if (preserve_tos) {
3402-
_VISIT(c, expr, s->v.Return.value);
3404+
VISIT(c, expr, s->v.Return.value);
34033405
} else {
34043406
/* Emit instruction with line number for return value */
34053407
if (s->v.Return.value != NULL) {
34063408
loc = LOC(s->v.Return.value);
3407-
_ADDOP(c, loc, NOP);
3409+
ADDOP(c, loc, NOP);
34083410
}
34093411
}
34103412
if (s->v.Return.value == NULL || s->v.Return.value->lineno != s->lineno) {
34113413
loc = LOC(s);
3412-
_ADDOP(c, loc, NOP);
3414+
AD 8000 DOP(c, loc, NOP);
34133415
}
34143416

3415-
if (compiler_unwind_fblock_stack(c, &loc, preserve_tos, NULL) < 0) {
3416-
return 0;
3417-
}
3417+
RETURN_IF_ERROR(compiler_unwind_fblock_stack(c, &loc, preserve_tos, NULL));
34183418
if (s->v.Return.value == NULL) {
3419-
_ADDOP_LOAD_CONST(c, loc, Py_None);
3419+
ADDOP_LOAD_CONST(c, loc, Py_None);
34203420
}
34213421
else if (!preserve_tos) {
3422-
_ADDOP_LOAD_CONST(c, loc, s->v.Return.value->v.Constant.value);
3422+
ADDOP_LOAD_CONST(c, loc, s->v.Return.value->v.Constant.value);
34233423
}
3424-
_ADDOP(c, loc, RETURN_VALUE);
3424+
ADDOP(c, loc, RETURN_VALUE);
34253425

3426-
return 1;
3426+
return SUCCESS;
34273427
}
34283428

34293429
static int
@@ -4203,7 +4203,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
42034203
case ClassDef_kind:
42044204
return compiler_class(c, s) == SUCCESS ? 1 : 0;
42054205
case Return_kind:
4206-
return compiler_return(c, s);
4206+
return compiler_return(c, s) == SUCCESS ? 1 : 0;
42074207
case Delete_kind:
42084208
_VISIT_SEQ(c, expr, s->v.Delete.targets)
42094209
break;

0 commit comments

Comments
 (0)
0