gh-151112: Fix crash in compiler_mod() when entering the current compilation unit fails (#151234)

This commit is contained in:
Stan Ulbrych
2026-06-11 15:52:11 +01:00
committed by GitHub
parent 0bbde07a0b
commit 937d89c4d9
+4 -1
View File
@@ -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;
}