Skip to content

Commit e1a5414

Browse files
committed
use RETURN_IF_ERROR in a few places
1 parent ef1001c commit e1a5414

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

Python/compile.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5308,10 +5308,9 @@ compiler_async_comprehension_generator(struct compiler *c, location loc,
53085308

53095309
USE_LABEL(c, start);
53105310
/* Runtime will push a block here, so we need to account for that */
5311-
if (compiler_push_fblock(c, loc, ASYNC_COMPREHENSION_GENERATOR,
5312-
start, NO_LABEL, NULL) < 0) {
5313-
return ERROR;
5314-
}
5311+
RETURN_IF_ERROR(
5312+
compiler_push_fblock(c, loc, ASYNC_COMPREHENSION_GENERATOR,
5313+
start, NO_LABEL, NULL));
53155314

53165315
ADDOP_JUMP(c, loc, SETUP_FINALLY, except);
53175316
ADDOP(c, loc, GET_ANEXT);
@@ -5631,8 +5630,8 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
56315630
/* BLOCK code */
56325631
VISIT_SEQ(c, stmt, s->v.AsyncWith.body)
56335632
}
5634-
else if (compiler_async_with(c, s, pos) == ERROR) {
5635-
return ERROR;
5633+
else {
5634+
RETURN_IF_ERROR(compiler_async_with(c, s, pos));
56365635
}
56375636

56385637
compiler_pop_fblock(c, ASYNC_WITH, block);
@@ -5725,8 +5724,8 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
57255724
/* BLOCK code */
57265725
VISIT_SEQ(c, stmt, s->v.With.body)
57275726
}
5728-
else if (compiler_with(c, s, pos) == ERROR) {
5729-
return ERROR;
5727+
else {
5728+
RETURN_IF_ERROR(compiler_with(c, s, pos));
57305729
}
57315730

57325731
ADDOP(c, NO_LOCATION, POP_BLOCK);
@@ -6346,20 +6345,14 @@ pattern_helper_store_name(struct compiler *c, location loc,
63466345
}
63476346
// Can't assign to the same name twice:
63486347
int duplicate = PySequence_Contains(pc->stores, n);
6349-
if (duplicate < 0) {
6350-
return ERROR;
6351-
}
6348+
RETURN_IF_ERROR(duplicate);
63526349
if (duplicate) {
63536350
return compiler_error_duplicate_store(c, loc, n);
63546351
}
63556352
// Rotate this object underneath any items we need to preserve:
63566353
Py_ssize_t rotations = pc->on_top + PyList_GET_SIZE(pc->stores) + 1;
6357-
if (pattern_helper_rotate(c, loc, rotations) < 0) {
6358-
return ERROR;
6359-
}
6360-
if (PyList_Append(pc->stores, n) < 0) {
6361-
return ERROR;
6362-
}
6354+
RETURN_IF_ERROR(pattern_helper_rotate(c, loc, rotations));
6355+
RETURN_IF_ERROR(PyList_Append(pc->stores, n));
63636356
return SUCCESS;
63646357
}
63656358

@@ -6398,9 +6391,7 @@ pattern_helper_sequence_unpack(struct compiler *c, location loc,
63986391
asdl_pattern_seq *patterns, Py_ssize_t star,
63996392
pattern_context *pc)
64006393
{
6401-
if (pattern_unpack_helper(c, loc, patterns) < 0) {
6402-
return ERROR;
6403-
}
6394+
RETURN_IF_ERROR(pattern_unpack_helper(c, loc, patterns));
64046395
Py_ssize_t size = asdl_seq_LEN(patterns);
64056396
// We've now got a bunch of new subjects on the stack. They need to remain
64066397
// there after each subpattern match:

0 commit comments

Comments
 (0)