Skip to content

Commit e9eb34f

Browse files
authored
[3.14] gh-156466: fix cleanup on error in codegen_leave_annotations_scope (#156522)
[3.14] gh-156466: fix cleanup on error in codegen_leave_annotations_scope
1 parent 1031cf4 commit e9eb34f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Python/codegen.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,11 @@ codegen_setup_annotations_scope(compiler *c, location loc,
700700
}
701701

702702
static int
703-
codegen_leave_annotations_scope(compiler *c, location loc)
703+
codegen_finish_annotations_scope(compiler *c, location loc)
704704
{
705705
ADDOP_IN_SCOPE(c, loc, RETURN_VALUE);
706706
PyCodeObject *co = _PyCompile_OptimizeAndAssemble(c, 1);
707+
_PyCompile_ExitScope(c);
707708
if (co == NULL) {
708709
return ERROR;
709710
}
@@ -737,7 +738,6 @@ codegen_leave_annotations_scope(compiler *c, location loc)
737738
}
738739
Py_SETREF(co->co_localsplusnames, new_names);
739740

740-
_PyCompile_ExitScope(c);
741741
int ret = codegen_make_closure(c, loc, co, 0);
742742
Py_DECREF(co);
743743
RETURN_IF_ERROR(ret);
@@ -837,7 +837,7 @@ codegen_process_deferred_annotations(compiler *c, location loc)
837837
Py_DECREF(deferred_anno);
838838
Py_DECREF(conditional_annotation_indices);
839839

840-
RETURN_IF_ERROR(codegen_leave_annotations_scope(c, loc));
840+
RETURN_IF_ERROR(codegen_finish_annotations_scope(c, loc));
841841
RETURN_IF_ERROR(codegen_nameop(
842842
c, loc,
843843
ste->ste_type == ClassBlock ? &_Py_ID(__annotate_func__) : &_Py_ID(__annotate__),
@@ -1143,7 +1143,7 @@ codegen_function_annotations(compiler *c, location loc,
11431143
c, codegen_annotations_in_scope(c, loc, args, returns, &annotations_len)
11441144
);
11451145
ADDOP_I_IN_SCOPE(c, loc, BUILD_MAP, annotations_len);
1146-
RETURN_IF_ERROR(codegen_leave_annotations_scope(c, loc));
1146+
RETURN_IF_ERROR(codegen_finish_annotations_scope(c, loc));
11471147
return MAKE_FUNCTION_ANNOTATE;
11481148
}
11491149
else {

0 commit comments

Comments
 (0)