https://github.com/python/cpython/commit/f7523edbb1ee3d016ff7110d5b01a2344347fca3
commit: f7523edbb1ee3d016ff7110d5b01a2344347fca3
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-10-10T14:00:18+03:00
summary:

[3.15] gh-156466: fix cleanup on error after Enter in codegen_enter_scope 
(GH-156467) (GH-156616)

(cherry picked from commit 41b3f0af266b408438cab36625c6ad71040d38e5)

Co-authored-by: Irit Katriel <[email protected]>

files:
M Python/codegen.c

diff --git a/Python/codegen.c b/Python/codegen.c
index 0e6d9d1739039d..491dc1262903ec 100644
--- a/Python/codegen.c
+++ b/Python/codegen.c
@@ -697,13 +697,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;
 }

_______________________________________________
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]

Reply via email to