Message 394310 - Python tracker

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Content
> The commit that fixes the issue in 3.10 is https://github.com/python/cpython/commit/7f1305ef9ea7234e1a5aacbea17490232e9b7dc2

Right, the _ssl module was ported to multiphase initialization (PEP 489) in bpo-42333 (fixed in Python 3.10.0a3).


> This is a regression in 3.9. It didn't happen in 3.8. The commit that introduced the issue is https://github.com/python/cpython/commit/82c83bd907409c287a5bd0d0f4598f2c0538f34d

In Python 3.9, some stdlib modules are still using the legacy API to initialize modules, and share states between interpreters. This is bad: no Python object (nor state) must be shared between two interpreters.

Well, there is an on-going work on subinterpreters:

* https://pyfound.blogspot.com/2021/05/the-2021-python-language-summit_16.html
* https://vstinner.github.io/isolate-subinterpreters.html

For example, many C extensions are being converted to the multiphase initialization API and get a "module state".

The _PyImport_FixupExtensionObject() change impacts extensions using the legacy API and so should not be used in subinterpreters.

Maybe the old behavior was better: if an extension uses the old API, share its state between all interpreters.