Skip to content

Commit 41b06cc

Browse files
committed
fix cleanup on errors in compiler
1 parent 5f31aee commit 41b06cc

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

‎Python/codegen.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5073,19 +5073,22 @@ codegen_comprehension(compiler *c, expr_ty e, int type,
50735073
if (type == COMP_GENEXP) {
50745074
/* Insert GET_ITER before RETURN_GENERATOR.
50755075
https://docs.python.org/3/reference/expressions.html#generator-expressions */
5076-
RETURN_IF_ERROR(
5077-
_PyInstructionSequence_InsertInstruction(
5076+
if(_PyInstructionSequence_InsertInstruction(
50785077
INSTR_SEQUENCE(c), 0,
5079-
RESUME, RESUME_AT_GEN_EXPR_START, NO_LOCATION));
5080-
RETURN_IF_ERROR(
5081-
_PyInstructionSequence_InsertInstruction(
5078+
RESUME, RESUME_AT_GEN_EXPR_START, NO_LOCATION) < 0) {
5079+
goto error_in_scope;
5080+
}
5081+
if(_PyInstructionSequence_InsertInstruction(
50825082
INSTR_SEQUENCE(c), 1,
5083-
LOAD_FAST, 0, LOC(outermost->iter)));
5084-
RETURN_IF_ERROR(
5085-
_PyInstructionSequence_InsertInstruction(
5083+
LOAD_FAST, 0, LOC(outermost->iter)) < 0) {
5084+
goto error_in_scope;
5085+
}
5086+
if(_PyInstructionSequence_InsertInstruction(
50865087
INSTR_SEQUENCE(c), 2,
50875088
outermost->is_async ? GET_AITER : GET_ITER,
5088-
0, LOC(outermost->iter)));
5089+
0, LOC(outermost->iter)) < 0) {
5090+
goto error_in_scope;
5091+
}
50895092
iter_state = ITERATOR_ON_STACK;
50905093
}
50915094
else {

0 commit comments

Comments
 (0)