[issue44050] [subinterpreters] _PyImport_FixupExtensionObject() regression in Python 3.9
STINNER Victor
report at bugs.python.org
Tue May 25 06:15:29 EDT 2021
STINNER Victor <vstinner at python.org> added the comment:
> 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.
----------
nosy: +corona10, erlendaasland, shihai1991 -christian.heimes
title: Exceptions in a subinterpreter are changed by another subinterpreter -> [subinterpreters] _PyImport_FixupExtensionObject() regression in Python 3.9
versions: +Python 3.10, Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44050>
_______________________________________
More information about the Python-bugs-list
mailing list