cpython: 9f1e680896ef (original) (raw)
Mercurial > cpython
changeset 100279:9f1e680896ef 3.5
Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. The class was checking its argument as to whether its implementation of create_module() came directly from importlib.abc.Loader. The problem is that the classes coming from imoprtlib.machinery do not directly inherit from the ABC as they come from _frozen_importlib. Because the documentation has always said that create_module() was ignored, the check has simply been removed. [#26186]
Brett Cannon brett@python.org | |
---|---|
date | Sat, 20 Feb 2016 18:35:41 -0800 |
parents | e523efd47418 |
children | 86fc6cdd65de 43c6d087035d |
files | Lib/importlib/abc.py Lib/importlib/util.py Lib/test/test_importlib/test_lazy.py Misc/NEWS |
diffstat | 4 files changed, 3 insertions(+), 6 deletions(-)[+] [-] Lib/importlib/abc.py 1 Lib/importlib/util.py 5 Lib/test/test_importlib/test_lazy.py 1 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -4,7 +4,6 @@ from . import _bootstrap_external from . import machinery try: import _frozen_importlib -# import _frozen_importlib_external except ImportError as exc: if exc.name != '_frozen_importlib': raise
--- a/Lib/importlib/util.py +++ b/Lib/importlib/util.py @@ -263,11 +263,6 @@ class LazyLoader(abc.Loader): def __check_eager_loader(loader): if not hasattr(loader, 'exec_module'): raise TypeError('loader must define exec_module()')
elif hasattr(loader.__class__, 'create_module'):[](#l2.7)
if abc.Loader.create_module != loader.__class__.create_module:[](#l2.8)
# Only care if create_module() is overridden in a subclass of[](#l2.9)
# importlib.abc.Loader.[](#l2.10)
raise TypeError('loader cannot define create_module()')[](#l2.11)
@classmethod def factory(cls, loader):
--- a/Lib/test/test_importlib/test_lazy.py +++ b/Lib/test/test_importlib/test_lazy.py @@ -54,6 +54,7 @@ class LazyLoaderTests(unittest.TestCase) def test_init(self): with self.assertRaises(TypeError):
# Classes that dono't define exec_module() trigger TypeError.[](#l3.7) util.LazyLoader(object)[](#l3.8)
def new_module(self, source_code=None):
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -76,6 +76,8 @@ Core and Builtins Library ------- +- Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. +