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
Next Next commit
Get rid of the default argument.
  • Loading branch information
ericsnowcurrently committed Jun 2, 2023
commit bec03a22a652bf4168b454b360287e5299f6eba7
8 changes: 4 additions & 4 deletions Lib/importlib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class _incompatible_extension_module_restrictions:
extension module development.

If "disable_check" is True then the compatibility check will not
happen while the context manager is active. Otherwise (and by
default) the check *will* happen.
happen while the context manager is active. Otherwise the check
*will* happen.

Normally, extensions that do not support multiple interpreters
may not be imported in a subinterpreter. That implies modules
Expand All @@ -148,8 +148,8 @@ class _incompatible_extension_module_restrictions:
support for mulitple interpreters (or per-interpreter GIL).
"""

def __init__(self, disable_check=False):
self.disable_check = disable_check
def __init__(self, disable_check):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the keyword, _incompatible_extension_module_restrictions(True) reads to me like incompatible module restrictions are turned on. I would either make the parameter keyword-only or invert the meaning (i.e., enable_check).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

self.disable_check = bool(disable_check)

def __enter__(self):
self.old = _imp._override_multi_interp_extensions_check(self.override)
Expand Down
9 changes: 0 additions & 9 deletions Lib/test/test_importlib/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,15 +699,6 @@ def test_single_phase_init_module(self):
with self.assertRaises(ImportError):
self.run_with_own_gil(script)

script = textwrap.dedent(f'''
import importlib.util
with importlib.util._incompatible_extension_module_restrictions():
import _testsinglephase
''')
with self.subTest('check enabled (default)'):
with self.assertRaises(ImportError):
self.run_with_shared_gil(script)

@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
def test_incomplete_multi_phase_init_module(self):
prescript = textwrap.dedent(f'''
Expand Down