Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Use a keyword-only parameter.
  • Loading branch information
ericsnowcurrently committed Jun 8, 2023
commit 760238e0ac8de8b3895a3eac1f0e3e4d9995c25c
2 changes: 1 addition & 1 deletion Lib/importlib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class _incompatible_extension_module_restrictions:
support for mulitple interpreters (or per-interpreter GIL).
"""

def __init__(self, disable_check):
def __init__(self, *, disable_check):
self.disable_check = bool(disable_check)

def __enter__(self):
Expand Down
24 changes: 12 additions & 12 deletions Lib/test/test_importlib/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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._incompatible_extension_module_restrictions(True):
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._incompatible_extension_module_restrictions(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._incompatible_extension_module_restrictions(True):
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._incompatible_extension_module_restrictions(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._incompatible_extension_module_restrictions(True):
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._incompatible_extension_module_restrictions(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