@@ -1900,6 +1900,7 @@ def test_single_init_extension_compat(self):
19001900
19011901 @unittest .skipIf (_testmultiphase is None , "test requires _testmultiphase module" )
19021902 def test_multi_init_extension_compat (self ):
1903+ # Module with Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
19031904 module = '_testmultiphase'
19041905 require_extension (module )
19051906 with self .subTest (f'{ module } : not strict' ):
@@ -1911,6 +1912,8 @@ def test_multi_init_extension_compat(self):
19111912
19121913 @unittest .skipIf (_testmultiphase is None , "test requires _testmultiphase module" )
19131914 def test_multi_init_extension_non_isolated_compat (self ):
1915+ # Module with Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED
1916+ # and Py_MOD_GIL_NOT_USED
19141917 modname = '_test_non_isolated'
19151918 filename = _testmultiphase .__file__
19161919 loader = ExtensionFileLoader (modname , filename )
@@ -1929,23 +1932,33 @@ def test_multi_init_extension_non_isolated_compat(self):
19291932
19301933 @unittest .skipIf (_testmultiphase is None , "test requires _testmultiphase module" )
19311934 def test_multi_init_extension_per_interpreter_gil_compat (self ):
1932- modname = '_test_shared_gil_only'
1933- filename = _testmultiphase .__file__
1934- loader = ExtensionFileLoader (modname , filename )
1935- spec = importlib .util .spec_from_loader (modname , loader )
1936- module = importlib .util .module_from_spec (spec )
1937- loader .exec_module (module )
1938- sys .modules [modname ] = module
1939-
1940- require_extension (module )
1941- with self .subTest (f'{ modname } : isolated, strict' ):
1942- self .check_incompatible_here (modname , filename , isolated = True )
1943- with self .subTest (f'{ modname } : not isolated, strict' ):
1944- self .check_compatible_here (modname , filename ,
1945- strict = True , isolated = False )
1946- with self .subTest (f'{ modname } : not isolated, not strict' ):
1947- self .check_compatible_here (modname , filename ,
1948- strict = False , isolated = False )
1935+ # _test_shared_gil_only:
1936+ # Explicit Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED (default)
1937+ # and Py_MOD_GIL_NOT_USED
1938+ # _test_no_multiple_interpreter_slot:
1939+ # No Py_mod_multiple_interpreters slot
1940+ # and Py_MOD_GIL_NOT_USED
1941+ for modname in ('_test_shared_gil_only' ,
1942+ '_test_no_multiple_interpreter_slot' ):
1943+ with self .subTest (modname = modname ):
1944+
1945+ filename = _testmultiphase .__file__
1946+ loader = ExtensionFileLoader (modname , filename )
1947+ spec = importlib .util .spec_from_loader (modname , loader )
1948+ module = importlib .util .module_from_spec (spec )
1949+ loader .exec_module (module )
1950+ sys .modules [modname ] = module
1951+
1952+ require_extension (module )
1953+ with self .subTest (f'{ modname } : isolated, strict' ):
1954+ self .check_incompatible_here (modname , filename ,
1955+ isolated = True )
1956+ with self .subTest (f'{ modname } : not isolated, strict' ):
1957+ self .check_compatible_here (modname , filename ,
1958+ strict = True , isolated = False )
1959+ with self .subTest (f'{ modname } : not isolated, not strict' ):
1960+ self .check_compatible_here (
1961+ modname , filename , strict = False , isolated = False )
19491962
19501963 def test_python_compat (self ):
19511964 module = 'threading'
0 commit comments