Skip to content
Prev Previous commit
Next Next commit
Skip two more tests that use `_imp._override_multi_interp_extensions_…
…check`
  • Loading branch information
colesbury committed Apr 9, 2024
commit c1c1b3b740af51f216588a6a64dfddaa396ca7c5
20 changes: 6 additions & 14 deletions Lib/test/test_importlib/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,26 +682,17 @@ def ensure_destroyed():
raise ImportError(excsnap.msg)

@unittest.skipIf(_testsinglephase is None, "test requires _testsinglephase module")
@support.requires_gil_enabled("gh-117649: not supported in free-threaded build")
def test_single_phase_init_module(self):
script = textwrap.dedent('''
from importlib.util import _incompatible_extension_module_restrictions
with _incompatible_extension_module_restrictions(disable_check=True):
import _testsinglephase
''')
if not support.Py_GIL_DISABLED:
with self.subTest('check disabled, shared GIL'):
self.run_with_shared_gil(script)
with self.subTest('check disabled, per-interpreter GIL'):
self.run_with_own_gil(script)
else:
# gh-117649: Py_GIL_DISABLED builds do not support legacy
# single-phase init extensions within subinterpreters.
with self.subTest('check disabled, shared GIL'):
with self.assertRaises(ImportError):
self.run_with_shared_gil(script)
with self.subTest('check disabled, per-interpreter GIL'):
with self.assertRaises(ImportError):
self.run_with_own_gil(script)
with self.subTest('check disabled, shared GIL'):
self.run_with_shared_gil(script)
with self.subTest('check disabled, per-interpreter GIL'):
self.run_with_own_gil(script)

script = textwrap.dedent(f'''
from importlib.util import _incompatible_extension_module_restrictions
Expand All @@ -716,6 +707,7 @@ def test_single_phase_init_module(self):
self.run_with_own_gil(script)

@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
@support.requires_gil_enabled("gh-117649: not supported in free-threaded build")
def test_incomplete_multi_phase_init_module(self):
# Apple extensions must be distributed as frameworks. This requires
# a specialist loader.
Expand Down
2 changes: 2 additions & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -3689,6 +3689,7 @@ _imp__override_multi_interp_extensions_check_impl(PyObject *module,
int override)
/*[clinic end generated code: output=3ff043af52bbf280 input=e086a2ea181f92ae]*/
{
printf("_imp__override_multi_interp_extensions_check_impl: %d\n", override);
Comment thread
colesbury marked this conversation as resolved.
Outdated
PyInterpreterState *interp = _PyInterpreterState_GET();
if (_Py_IsMainInterpreter(interp)) {
PyErr_SetString(PyExc_RuntimeError,
Expand All @@ -3697,6 +3698,7 @@ _imp__override_multi_interp_extensions_check_impl(PyObject *module,
return NULL;
}
#ifdef Py_GIL_DISABLED
printf("Setting exception\n");
Comment thread
colesbury marked this conversation as resolved.
Outdated
PyErr_SetString(PyExc_RuntimeError,
"_imp._override_multi_interp_extensions_check() "
"cannot be used in the free-threaded build");
Expand Down