forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-117953: Always Run Extension Init Func in Main Interpreter F…
…irst (pythongh-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.
- Loading branch information
1 parent
69baf02
commit c1d5643
Showing
4 changed files
with
216 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import os | ||
from test.support import load_package_tests | ||
from test.support import load_package_tests, Py_GIL_DISABLED | ||
|
||
def load_tests(*args): | ||
return load_package_tests(os.path.dirname(__file__), *args) | ||
if not Py_GIL_DISABLED: | ||
def load_tests(*args): | ||
return load_package_tests(os.path.dirname(__file__), *args) |
8 changes: 8 additions & 0 deletions
8
Misc/NEWS.d/next/Core and Builtins/2024-05-06-10-57-54.gh-issue-117953.DqCzIs.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters