[Python-checkins] cpython (3.5): Issue #26186: Remove an invalid type check in
brett.cannon
python-checkins at python.org
Sat Feb 20 21:37:10 EST 2016
https://hg.python.org/cpython/rev/9f1e680896ef
changeset: 100279:9f1e680896ef
branch: 3.5
parent: 100277:e523efd47418
user: Brett Cannon <brett at python.org>
date: Sat Feb 20 18:35:41 2016 -0800
summary:
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.
files:
Lib/importlib/abc.py | 1 -
Lib/importlib/util.py | 5 -----
Lib/test/test_importlib/test_lazy.py | 1 +
Misc/NEWS | 2 ++
4 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
--- a/Lib/importlib/abc.py
+++ b/Lib/importlib/abc.py
@@ -4,7 +4,6 @@
from . import machinery
try:
import _frozen_importlib
-# import _frozen_importlib_external
except ImportError as exc:
if exc.name != '_frozen_importlib':
raise
diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py
--- a/Lib/importlib/util.py
+++ b/Lib/importlib/util.py
@@ -263,11 +263,6 @@
def __check_eager_loader(loader):
if not hasattr(loader, 'exec_module'):
raise TypeError('loader must define exec_module()')
- elif hasattr(loader.__class__, 'create_module'):
- if abc.Loader.create_module != loader.__class__.create_module:
- # Only care if create_module() is overridden in a subclass of
- # importlib.abc.Loader.
- raise TypeError('loader cannot define create_module()')
@classmethod
def factory(cls, loader):
diff --git a/Lib/test/test_importlib/test_lazy.py b/Lib/test/test_importlib/test_lazy.py
--- a/Lib/test/test_importlib/test_lazy.py
+++ b/Lib/test/test_importlib/test_lazy.py
@@ -54,6 +54,7 @@
def test_init(self):
with self.assertRaises(TypeError):
+ # Classes that dono't define exec_module() trigger TypeError.
util.LazyLoader(object)
def new_module(self, source_code=None):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -76,6 +76,8 @@
Library
-------
+- Issue #26186: Remove an invalid type check in importlib.util.LazyLoader.
+
- Issue #26367: importlib.__init__() raises RuntimeError like
builtins.__import__() when ``level`` is specified but without an accompanying
package specified.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list