summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-06-17 20:33:38 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-06-17 20:33:38 (GMT)
commit48114b952b22cf68ab7dccfb571a2194fd89e6ef (patch)
tree092accea1abbecaddf80290dd092ed1b6f0dfc12 /Lib/importlib
parent7636b193661f19eb21d35437c9f022cc7fc80e9f (diff)
downloadcpython-48114b952b22cf68ab7dccfb571a2194fd89e6ef.zip
cpython-48114b952b22cf68ab7dccfb571a2194fd89e6ef.tar.gz
cpython-48114b952b22cf68ab7dccfb571a2194fd89e6ef.tar.bz2
Issue #14657: The frozen instance of importlib used for bootstrap is now also the module imported as importlib._bootstrap.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/__init__.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index 90e163c..e62bdb1 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -1,21 +1,28 @@
"""A pure Python implementation of import."""
__all__ = ['__import__', 'import_module', 'invalidate_caches']
-from . import _bootstrap
+# Bootstrap help #####################################################
+import imp
+import sys
+try:
+ _bootstrap = sys.modules['_frozen_importlib']
+except ImportError:
+ from . import _bootstrap
+ _bootstrap._setup(sys, imp)
+else:
+ # importlib._bootstrap is the built-in import, ensure we don't create
+ # a second copy of the module.
+ _bootstrap.__name__ = 'importlib._bootstrap'
+ _bootstrap.__package__ = 'importlib'
+ _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py')
+ sys.modules['importlib._bootstrap'] = _bootstrap
# To simplify imports in test code
_w_long = _bootstrap._w_long
_r_long = _bootstrap._r_long
-# Bootstrap help #####################################################
-import imp
-import sys
-
-_bootstrap._setup(sys, imp)
-
-
# Public API #########################################################
from ._bootstrap import __import__