From 82463c54a2b227ea47e9af13a5a2b0a89b35332c Mon Sep 17 00:00:00 2001 From: xiejunyi Date: Mon, 22 Mar 2021 16:12:22 +0800 Subject: [PATCH] bpo-43588: use static variable module under building Python with --with-experimental-isolated-subinterpreters cause crash. --- Python/compile.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 27274ec884dc3f..67785414b8208b 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1868,14 +1868,14 @@ compiler_body(struct compiler *c, asdl_stmt_seq *stmts) static PyCodeObject * compiler_mod(struct compiler *c, mod_ty mod) { + _Py_static_string(_module, ""); PyCodeObject *co; int addNone = 1; - static PyObject *module; - if (!module) { - module = PyUnicode_InternFromString(""); - if (!module) - return NULL; + PyObject *module = _PyUnicode_FromId(&_module); // borrowed ref + if (module == NULL) { + return NULL; } + /* Use 0 for firstlineno initially, will fixup in assemble(). */ if (!compiler_enter_scope(c, module, COMPILER_SCOPE_MODULE, mod, 1)) return NULL;