[Python-checkins] cpython: Issue 19713: Remove PEP 451-related code that should have been factored out.
eric.snow
python-checkins at python.org
Wed Jan 8 07:33:35 CET 2014
http://hg.python.org/cpython/rev/c0b0e7aef360
changeset: 88353:c0b0e7aef360
parent: 88351:20b77ff040b6
user: Eric Snow <ericsnowcurrently at gmail.com>
date: Tue Jan 07 23:29:19 2014 -0700
summary:
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.
files:
Lib/importlib/_bootstrap.py | 28 +-
Python/importlib.h | 2405 +++++++++++-----------
2 files changed, 1192 insertions(+), 1241 deletions(-)
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -994,25 +994,11 @@
"""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 @@
# 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:
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list