@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
def test_multi_init_extension_compat(self):
+ # Module with Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
module = '_testmultiphase'
require_extension(module)
with self.subTest(f'{module}: not strict'):
@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
def test_multi_init_extension_non_isolated_compat(self):
+ # Module with Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED
+ # and Py_MOD_GIL_NOT_USED
modname = '_test_non_isolated'
filename = _testmultiphase.__file__
loader = ExtensionFileLoader(modname, filename)
@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
def test_multi_init_extension_per_interpreter_gil_compat(self):
- modname = '_test_shared_gil_only'
- filename = _testmultiphase.__file__
- loader = ExtensionFileLoader(modname, filename)
- spec = importlib.util.spec_from_loader(modname, loader)
- module = importlib.util.module_from_spec(spec)
- loader.exec_module(module)
- sys.modules[modname] = module
-
- require_extension(module)
- with self.subTest(f'{modname}: isolated, strict'):
- self.check_incompatible_here(modname, filename, isolated=True)
- with self.subTest(f'{modname}: not isolated, strict'):
- self.check_compatible_here(modname, filename,
- strict=True, isolated=False)
- with self.subTest(f'{modname}: not isolated, not strict'):
- self.check_compatible_here(modname, filename,
- strict=False, isolated=False)
+ # _test_shared_gil_only:
+ # Explicit Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED (default)
+ # and Py_MOD_GIL_NOT_USED
+ # _test_no_multiple_interpreter_slot:
+ # No Py_mod_multiple_interpreters slot
+ # and Py_MOD_GIL_NOT_USED
+ for modname in ('_test_shared_gil_only',
+ '_test_no_multiple_interpreter_slot'):
+ with self.subTest(modname=modname):
+
+ filename = _testmultiphase.__file__
+ loader = ExtensionFileLoader(modname, filename)
+ spec = importlib.util.spec_from_loader(modname, loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+ sys.modules[modname] = module
+
+ require_extension(module)
+ with self.subTest(f'{modname}: isolated, strict'):
+ self.check_incompatible_here(modname, filename,
+ isolated=True)
+ with self.subTest(f'{modname}: not isolated, strict'):
+ self.check_compatible_here(modname, filename,
+ strict=True, isolated=False)
+ with self.subTest(f'{modname}: not isolated, not strict'):
+ self.check_compatible_here(
+ modname, filename, strict=False, isolated=False)
def test_python_compat(self):
module = 'threading'