https://github.com/python/cpython/commit/937d89c4d9b7c5fda6730a1127db118d881d13cb
commit: 937d89c4d9b7c5fda6730a1127db118d881d13cb
branch: main
author: Stan Ulbrych <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-06-11T15:52:11+01:00
summary:
gh-151112: Fix crash in `compiler_mod()` when entering the current compilation
unit fails (#151234)
files:
M Python/compile.c
diff --git a/Python/compile.c b/Python/compile.c
index eb9fc827bea40a8..e223ef42a42e22b 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -893,12 +893,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;
}
_______________________________________________
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]