cpython/Misc/NEWS.d/next/Core and Builtins/2024-05-06-10-57-54.gh-issue-117953.DqCzIs.rst
Eric Snow b2cd54a4fb
gh-117953: Always Run Extension Init Func in Main Interpreter First (gh-118157)
This change makes sure all extension/builtin modules have their init function run first by the main interpreter before proceeding with import in the original interpreter (main or otherwise).  This means when the import of a single-phase init module fails in an isolated subinterpreter, it won't tie any global state/callbacks to the subinterpreter.
2024-05-07 04:21:51 +00:00

8 lines
537 B
ReStructuredText

When a builtin or extension module is imported for the first time, while a
subinterpreter is active, the module's init function is now run by the main
interpreter first before import continues in the subinterpreter.
Consequently, single-phase init modules now fail in an isolated
subinterpreter without the init function running under that interpreter,
whereas before it would run under the subinterpreter *before* failing,
potentially leaving behind global state and callbacks and otherwise leaving
the module in an inconsistent state.