https://github.com/python/cpython/commit/e9eb34f3909611ef5efb56b7a49a4ac16e23fe86
commit: e9eb34f3909611ef5efb56b7a49a4ac16e23fe86
branch: 3.14
author: Irit Katriel <[email protected]>
committer: iritkatriel <[email protected]>
date: 2026-08-30T14:13:40+01:00
summary:
[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
files:
M Python/codegen.c
diff --git a/Python/codegen.c b/Python/codegen.c
index 18c1fd9fa127ce..c532a859a97ec7 100644
--- a/Python/codegen.c
+++ b/Python/codegen.c
@@ -700,10 +700,11 @@ codegen_setup_annotations_scope(compiler *c, location loc,
}
static int
-codegen_leave_annotations_scope(compiler *c, location loc)
+codegen_finish_annotations_scope(compiler *c, location loc)
{
ADDOP_IN_SCOPE(c, loc, RETURN_VALUE);
PyCodeObject *co = _PyCompile_OptimizeAndAssemble(c, 1);
+ _PyCompile_ExitScope(c);
if (co == NULL) {
return ERROR;
}
@@ -737,7 +738,6 @@ codegen_leave_annotations_scope(compiler *c, location loc)
}
Py_SETREF(co->co_localsplusnames, new_names);
- _PyCompile_ExitScope(c);
int ret = codegen_make_closure(c, loc, co, 0);
Py_DECREF(co);
RETURN_IF_ERROR(ret);
@@ -837,7 +837,7 @@ codegen_process_deferred_annotations(compiler *c, location
loc)
Py_DECREF(deferred_anno);
Py_DECREF(conditional_annotation_indices);
- RETURN_IF_ERROR(codegen_leave_annotations_scope(c, loc));
+ RETURN_IF_ERROR(codegen_finish_annotations_scope(c, loc));
RETURN_IF_ERROR(codegen_nameop(
c, loc,
ste->ste_type == ClassBlock ? &_Py_ID(__annotate_func__) :
&_Py_ID(__annotate__),
@@ -1143,7 +1143,7 @@ codegen_function_annotations(compiler *c, location loc,
c, codegen_annotations_in_scope(c, loc, args, returns,
&annotations_len)
);
ADDOP_I_IN_SCOPE(c, loc, BUILD_MAP, annotations_len);
- RETURN_IF_ERROR(codegen_leave_annotations_scope(c, loc));
+ RETURN_IF_ERROR(codegen_finish_annotations_scope(c, loc));
return MAKE_FUNCTION_ANNOTATE;
}
else {
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]