diff options
author | Sam Gross <colesbury@gmail.com> | 2024-04-11 19:00:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 19:00:54 (GMT) |
commit | 25f6ff5d3e92305659db62e7f7545f823f0dbd05 (patch) | |
tree | 3fe6dd2136780028874b6b3cde3ca8c4c903f033 /Python/pylifecycle.c | |
parent | 39d381f91e93559011587d764c1895ee30efb741 (diff) | |
download | cpython-25f6ff5d3e92305659db62e7f7545f823f0dbd05.zip cpython-25f6ff5d3e92305659db62e7f7545f823f0dbd05.tar.gz cpython-25f6ff5d3e92305659db62e7f7545f823f0dbd05.tar.bz2 |
gh-117649: Raise ImportError for unsupported modules in free-threaded build (#117651)
The free-threaded build does not currently support the combination of
single-phase init modules and non-isolated subinterpreters. Ensure that
`check_multi_interp_extensions` is always `True` for subinterpreters in
the free-threaded build so that importing these modules raises an
`ImportError`.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 4e83b16..efb2587 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -559,6 +559,15 @@ init_interp_settings(PyInterpreterState *interp, return _PyStatus_ERR("per-interpreter obmalloc does not support " "single-phase init extension modules"); } +#ifdef Py_GIL_DISABLED + if (!_Py_IsMainInterpreter(interp) && + !config->check_multi_interp_extensions) + { + return _PyStatus_ERR("The free-threaded build does not support " + "single-phase init extension modules in " + "subinterpreters"); + } +#endif if (config->allow_fork) { interp->feature_flags |= Py_RTFLAGS_FORK; @@ -647,8 +656,10 @@ pycore_create_interpreter(_PyRuntimeState *runtime, } PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT; - // The main interpreter always has its own GIL. + // The main interpreter always has its own GIL and supports single-phase + // init extensions. config.gil = PyInterpreterConfig_OWN_GIL; + config.check_multi_interp_extensions = 0; status = init_interp_settings(interp, &config); if (_PyStatus_EXCEPTION(status)) { return status; |