mirror of
https://github.com/python/cpython
synced 2026-09-26 16:21:04 +03:00
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.
8 lines
537 B
ReStructuredText
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.
|