bpo-44050: Extension modules can share state when they don't support sub-interpreters. (GH-27794)

Automerge-Triggered-By: GH:encukou
This commit is contained in:
Hai Shi 2021-10-05 21:19:32 +08:00 committed by GitHub
parent 5146877623
commit b9bb74871b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 1 deletions

View file

@ -442,7 +442,9 @@ _PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
return -1;
}
if (_Py_IsMainInterpreter(tstate->interp)) {
// bpo-44050: Extensions and def->m_base.m_copy can be updated
// when the extension module doesn't support sub-interpreters.
if (_Py_IsMainInterpreter(tstate->interp) || def->m_size == -1) {
if (def->m_size == -1) {
if (def->m_base.m_copy) {
/* Somebody already imported the module,