gh-104310: Rename the New Function in importlib.util by ericsnowcurrently · Pull Request #105255 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions Lib/importlib/util.py
26 changes: 13 additions & 13 deletions Lib/test/test_importlib/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def test_magic_number(self):


@unittest.skipIf(_interpreters is None, 'subinterpreters required')
class AllowingAllExtensionsTests(unittest.TestCase):
class IncompatibleExtensionModuleRestrictionsTests(unittest.TestCase):

ERROR = re.compile("^<class 'ImportError'>: module (.*) does not support loading in subinterpreters")

Expand All @@ -678,8 +678,8 @@ def run_with_shared_gil(self, script):
@unittest.skipIf(_testsinglephase is None, "test requires _testsinglephase module")
def test_single_phase_init_module(self):
script = textwrap.dedent('''
import importlib.util
with importlib.util.allowing_all_extensions():
from importlib.util import _incompatible_extension_module_restrictions
with _incompatible_extension_module_restrictions(disable_check=True):
import _testsinglephase
''')
with self.subTest('check disabled, shared GIL'):
Expand All @@ -688,8 +688,8 @@ def test_single_phase_init_module(self):
self.run_with_own_gil(script)

script = textwrap.dedent(f'''
import importlib.util
with importlib.util.allowing_all_extensions(False):
from importlib.util import _incompatible_extension_module_restrictions
with _incompatible_extension_module_restrictions(disable_check=False):
import _testsinglephase
''')
with self.subTest('check enabled, shared GIL'):
Expand All @@ -713,8 +713,8 @@ def test_incomplete_multi_phase_init_module(self):
''')

script = prescript + textwrap.dedent('''
import importlib.util
with importlib.util.allowing_all_extensions():
from importlib.util import _incompatible_extension_module_restrictions
with _incompatible_extension_module_restrictions(disable_check=True):
module = module_from_spec(spec)
loader.exec_module(module)
''')
Expand All @@ -724,8 +724,8 @@ def test_incomplete_multi_phase_init_module(self):
self.run_with_own_gil(script)

script = prescript + textwrap.dedent('''
import importlib.util
with importlib.util.allowing_all_extensions(False):
from importlib.util import _incompatible_extension_module_restrictions
with _incompatible_extension_module_restrictions(disable_check=False):
module = module_from_spec(spec)
loader.exec_module(module)
''')
Expand All @@ -738,8 +738,8 @@ def test_incomplete_multi_phase_init_module(self):
@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
def test_complete_multi_phase_init_module(self):
script = textwrap.dedent('''
import importlib.util
with importlib.util.allowing_all_extensions():
from importlib.util import _incompatible_extension_module_restrictions
with _incompatible_extension_module_restrictions(disable_check=True):
import _testmultiphase
''')
with self.subTest('check disabled, shared GIL'):
Expand All @@ -748,8 +748,8 @@ def test_complete_multi_phase_init_module(self):
self.run_with_own_gil(script)

script = textwrap.dedent(f'''
import importlib.util
with importlib.util.allowing_all_extensions(False):
from importlib.util import _incompatible_extension_module_restrictions
with _incompatible_extension_module_restrictions(disable_check=False):
import _testmultiphase
''')
with self.subTest('check enabled, shared GIL'):
Expand Down