mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
[3.12] gh-104310: Rename the New Function in importlib.util (gh-105255) (gh-105518)
The original name wasn't as clear as it could have been. This change includes the following:
* rename the function
* change the default value for "disable_check" to False
* add clues to the docstring that folks should probably not use the function
---------
(cherry picked from commit 34c63b86d3
)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
parent
1f90b2f57a
commit
8698fa83f6
3 changed files with 41 additions and 18 deletions
|
@ -653,7 +653,7 @@ class MagicNumberTests(unittest.TestCase):
|
|||
|
||||
|
||||
@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")
|
||||
|
||||
|
@ -678,8 +678,8 @@ class AllowingAllExtensionsTests(unittest.TestCase):
|
|||
@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'):
|
||||
|
@ -688,8 +688,8 @@ class AllowingAllExtensionsTests(unittest.TestCase):
|
|||
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'):
|
||||
|
@ -713,8 +713,8 @@ class AllowingAllExtensionsTests(unittest.TestCase):
|
|||
''')
|
||||
|
||||
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)
|
||||
''')
|
||||
|
@ -724,8 +724,8 @@ class AllowingAllExtensionsTests(unittest.TestCase):
|
|||
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)
|
||||
''')
|
||||
|
@ -738,8 +738,8 @@ class AllowingAllExtensionsTests(unittest.TestCase):
|
|||
@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'):
|
||||
|
@ -748,8 +748,8 @@ class AllowingAllExtensionsTests(unittest.TestCase):
|
|||
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'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue