https://github.com/python/cpython/commit/164d5fb91a9476ecd1d4ecfffa34f1e72634d219
commit: 164d5fb91a9476ecd1d4ecfffa34f1e72634d219
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2026-08-31T12:49:27+03:00
summary:

[3.15] gh-156466: Fix additional compiler scope cleanup errors (GH-156547) 
(#156571)

Co-authored-by: Jelle Zijlstra <[email protected]>

files:
M Python/codegen.c
M Python/compile.c

diff --git a/Python/codegen.c b/Python/codegen.c
index 529c1733598e38..dbe889c5441182 100644
--- a/Python/codegen.c
+++ b/Python/codegen.c
@@ -1608,7 +1608,7 @@ codegen_class_body(compiler *c, stmt_ty s, int 
firstlineno)
         ADDOP_N_IN_SCOPE(c, loc, STORE_DEREF, &_Py_ID(__classdict__), 
cellvars);
     }
     if (SYMTABLE_ENTRY(c)->ste_has_conditional_annotations) {
-        ADDOP_I(c, loc, BUILD_SET, 0);
+        ADDOP_I_IN_SCOPE(c, loc, BUILD_SET, 0);
         ADDOP_N_IN_SCOPE(c, loc, STORE_DEREF, 
&_Py_ID(__conditional_annotations__), cellvars);
     }
     /* compile the body proper */
diff --git a/Python/compile.c b/Python/compile.c
index fefb2b04b78db8..2717037a988ec7 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1735,7 +1735,9 @@ _PyCompile_CodeGen(PyObject *ast, PyObject *filename, 
PyCompilerFlags *pflags,
 finally:
     Py_XDECREF(consts_list);
     Py_XDECREF(metadata);
-    _PyCompile_ExitScope(c);
+    if (c->u != NULL) {
+        _PyCompile_ExitScope(c);
+    }
     compiler_free(c);
     _PyArena_Free(arena);
     return res;

_______________________________________________
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