diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2014-01-08 06:29:19 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2014-01-08 06:29:19 (GMT) |
commit | e4314e05d5d96eed8a3f25db779f853fc5514969 (patch) | |
tree | 9f88e7eb05a47ae4f5d0b041a42876ee9a01a9b8 /Lib | |
parent | 2e385e2592c140897a106a6a95184b23c5611a7f (diff) | |
download | cpython-e4314e05d5d96eed8a3f25db779f853fc5514969.zip cpython-e4314e05d5d96eed8a3f25db779f853fc5514969.tar.gz cpython-e4314e05d5d96eed8a3f25db779f853fc5514969.tar.bz2 |
Issue 19713: Remove PEP 451-related code that should have been factored out.
This code was an artifact of issuing a DeprecationWarning for the lack
of loader.exec_module(). However, we have deferred such warnings to
later Python versions.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index a9d4885..8a0cc34 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -994,25 +994,11 @@ class _SpecMethods: """Convenience wrapper around spec objects to provide spec-specific methods.""" + # The various spec_from_* functions could be made factory methods here. + def __init__(self, spec): self.spec = spec - @classmethod - def from_module(cls, module): - """Create a spec from a module's attributes.""" - try: - spec = module.__spec__ - except AttributeError: - try: - loader = spec.__loader__ - except AttributeError: - spec = _find_spec(module.__name__) - if spec is None: - spec = spec_from_loader(module.__name__, loader) - else: - spec = spec_from_loader(module.__name__, loader) - return cls(spec) - def module_repr(self): """Return the repr to use for the module.""" # We mostly replicate _module_repr() using the spec attributes. @@ -1171,14 +1157,8 @@ class _SpecMethods: # have exec_module() implemented, we can add a deprecation # warning here. spec = self.spec - # The module must be in sys.modules! - try: - _warnings - except NameError: - # We must be importing builtins in setup(). - spec.loader.load_module(spec.name) - else: - spec.loader.load_module(spec.name) + spec.loader.load_module(spec.name) + # The module must be in sys.modules at this point! module = sys.modules[spec.name] if getattr(module, '__loader__', None) is None: try: |