summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorƁukasz Langa <lukasz@langa.pl>2021-10-05 20:30:25 (GMT)
committerGitHub <noreply@github.com>2021-10-05 20:30:25 (GMT)
commit52d9d3b75441ae6038fadead89eac5eecdd34501 (patch)
tree8d779959a1d0da0eb29bbfe7046d2a643e1ca93b /Python
parent950b324973a98ec45c21e7e7149415259a045ff7 (diff)
downloadcpython-52d9d3b75441ae6038fadead89eac5eecdd34501.zip
cpython-52d9d3b75441ae6038fadead89eac5eecdd34501.tar.gz
cpython-52d9d3b75441ae6038fadead89eac5eecdd34501.tar.bz2
[3.9] bpo-44050: Extension modules can share state when they don't support sub-interpreters. (GH-27794) (GH-28741)
(cherry picked from commit b9bb74871b27d9226df2dd3fce9d42bda8b43c2b) Co-authored-by: Hai Shi <shihai1992@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/import.c b/Python/import.c
index 1ec7553..8358d70 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -710,7 +710,9 @@ _PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
return -1;
}
- if (_Py_IsMainInterpreter(tstate)) {
+ // 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) || def->m_size == -1) {
if (def->m_size == -1) {
if (def->m_base.m_copy) {
/* Somebody already imported the module,