summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-02-14 23:38:11 (GMT)
committerBrett Cannon <brett@python.org>2012-02-14 23:38:11 (GMT)
commit0568d6fd4e048c0fb3ffca0f9c8005e3f1256203 (patch)
tree6433852177f208a8bf931608a71d4106ce1f3c24
parent06b57ef9586c8095b38b58dbf04fb8de94c08c16 (diff)
downloadcpython-0568d6fd4e048c0fb3ffca0f9c8005e3f1256203.zip
cpython-0568d6fd4e048c0fb3ffca0f9c8005e3f1256203.tar.gz
cpython-0568d6fd4e048c0fb3ffca0f9c8005e3f1256203.tar.bz2
Bring importlib in line w/ changes made in my personal bootstrap branch in the sandbox.
-rw-r--r--Lib/importlib/_bootstrap.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 9d12e32..f0650dd 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -10,6 +10,7 @@ work. One should use importlib as the public-facing version of this module.
# Injected modules are '_warnings', 'imp', 'sys', 'marshal', '_io',
# and '_os' (a.k.a. 'posix', 'nt' or 'os2').
# Injected attribute is path_sep.
+# Most injection is handled by _setup().
#
# When editing this code be aware that code executed at import time CANNOT
# reference any injected objects! This includes not only global code but also
@@ -999,7 +1000,7 @@ def _setup(sys_module, imp_module):
into the global namespace.
As sys is needed for sys.modules access and imp is needed to load built-in
- modules those two modules must be explicitly passed in.
+ modules, those two modules must be explicitly passed in.
"""
global imp, sys
@@ -1035,3 +1036,16 @@ def _setup(sys_module, imp_module):
raise ImportError('importlib requires posix or nt')
setattr(self_module, '_os', os_module)
setattr(self_module, 'path_sep', path_sep)
+
+
+def _install(sys_module, imp_module):
+ """Install importlib as the implementation of import.
+
+ It is assumed that imp and sys have been imported and injected into the
+ global namespace for the module prior to calling this function.
+
+ """
+ _setup(sys_module, imp_module)
+ orig_import = builtins.__import__
+ builtins.__import__ = __import__
+ builtins.__original_import__ = orig_import