summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/__init__.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2015-05-03 01:15:18 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2015-05-03 01:15:18 (GMT)
commit32439d6eb63f1ea31aed1e45459f0f50f965ef51 (patch)
tree8603d0565af4892f25b0361e46ffedcc35624f30 /Lib/importlib/__init__.py
parent6b4c63dea5a1e470849a6925c1b29faea2b01636 (diff)
downloadcpython-32439d6eb63f1ea31aed1e45459f0f50f965ef51.zip
cpython-32439d6eb63f1ea31aed1e45459f0f50f965ef51.tar.gz
cpython-32439d6eb63f1ea31aed1e45459f0f50f965ef51.tar.bz2
Issue #23911: Move path-based bootstrap code to a separate frozen module.
Diffstat (limited to 'Lib/importlib/__init__.py')
-rw-r--r--Lib/importlib/__init__.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index e99f50e..349b846 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -30,9 +30,25 @@ else:
pass
sys.modules['importlib._bootstrap'] = _bootstrap
+try:
+ import _frozen_importlib_external as _bootstrap_external
+except ImportError:
+ from . import _bootstrap_external
+ _bootstrap_external._setup(_bootstrap)
+else:
+ _bootstrap_external.__name__ = 'importlib._bootstrap_external'
+ _bootstrap_external.__package__ = 'importlib'
+ try:
+ _bootstrap_external.__file__ = __file__.replace('__init__.py', '_bootstrap_external.py')
+ except NameError:
+ # __file__ is not guaranteed to be defined, e.g. if this code gets
+ # frozen by a tool like cx_Freeze.
+ pass
+ sys.modules['importlib._bootstrap_external'] = _bootstrap_external
+
# To simplify imports in test code
-_w_long = _bootstrap._w_long
-_r_long = _bootstrap._r_long
+_w_long = _bootstrap_external._w_long
+_r_long = _bootstrap_external._r_long
# Fully bootstrapped at this point, import whatever you like, circular
# dependencies and startup overhead minimisation permitting :)