From d0d8d4f7d3acb29970919a7c60c7227dd8e1b7a4 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Thu, 27 Aug 2026 14:17:24 +0100 Subject: [PATCH] gh-156466: fix cleanup on error after Enter in codegen_enter_scope --- Python/codegen.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Python/codegen.c b/Python/codegen.c index bedf3b17c52ce4..c6c5a9b5cc51af 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -695,13 +695,13 @@ codegen_enter_scope(compiler *c, identifier name, int scope_type, * of 0. This is because RETURN_GENERATOR pushes the generator before returning. */ location loc = LOCATION(lineno, lineno, -1, -1); - ADDOP(c, loc, RETURN_GENERATOR); - ADDOP(c, loc, POP_TOP); + ADDOP_IN_SCOPE(c, loc, RETURN_GENERATOR); + ADDOP_IN_SCOPE(c, loc, POP_TOP); } - ADDOP_I(c, loc, RESUME, RESUME_AT_FUNC_START); + ADDOP_I_IN_SCOPE(c, loc, RESUME, RESUME_AT_FUNC_START); if (scope_type == COMPILE_SCOPE_MODULE) { - ADDOP(c, loc, ANNOTATIONS_PLACEHOLDER); + ADDOP_IN_SCOPE(c, loc, ANNOTATIONS_PLACEHOLDER); } return SUCCESS; }