mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Issue #26186: Remove the restriction that built-in and extension
modules can't be lazily loaded. Thanks to Python 3.6 allowing for types.ModuleType to have its __class__ mutated, the restriction can be lifted by calling create_module() on the wrapped loader.
This commit is contained in:
parent
da037616b1
commit
696c35e86b
4 changed files with 50 additions and 27 deletions
|
@ -66,6 +66,8 @@ class LazyLoaderTests(unittest.TestCase):
|
|||
spec = util.spec_from_loader(TestingImporter.module_name,
|
||||
util.LazyLoader(loader))
|
||||
module = spec.loader.create_module(spec)
|
||||
if module is None:
|
||||
module = types.ModuleType(TestingImporter.module_name)
|
||||
module.__spec__ = spec
|
||||
module.__loader__ = spec.loader
|
||||
spec.loader.exec_module(module)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue