]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-151112: Fix crash in `compiler_mod()` when entering the current compilation...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 11 Jun 2026 15:16:58 +0000 (17:16 +0200)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2026 15:16:58 +0000 (15:16 +0000)
(cherry picked from commit 937d89c4d9b7c5fda6730a1127db118d881d13cb)

Co-authored-by: Stan Ulbrych <stan@python.org>
Python/compile.c

index d79e4b44c2c02cb5896e0b09407775adc47d36d9..ab2e532e43e8d180a8e0f5a0ac9acb085651498e 100644 (file)
@@ -853,12 +853,15 @@ compiler_mod(compiler *c, mod_ty mod)
 {
     PyCodeObject *co = NULL;
     int addNone = mod->kind != Expression_kind;
+    assert(c->u == NULL);
     if (compiler_codegen(c, mod) < 0) {
         goto finally;
     }
     co = _PyCompile_OptimizeAndAssemble(c, addNone);
 finally:
-    _PyCompile_ExitScope(c);
+    if (c->u != NULL) {
+        _PyCompile_ExitScope(c);
+    }
     return co;
 }