summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-04-27 18:01:58 (GMT)
committerBrett Cannon <brett@python.org>2012-04-27 18:01:58 (GMT)
commitce418b448f431f2e62f0517f337f5b6762f4ae45 (patch)
treeec7424354c7da9d2d19419d7619bbf1607915308 /Lib/importlib/_bootstrap.py
parent3c6ea1c14dc7a3eb67d46f96b3acdb83586f42ae (diff)
downloadcpython-ce418b448f431f2e62f0517f337f5b6762f4ae45.zip
cpython-ce418b448f431f2e62f0517f337f5b6762f4ae45.tar.gz
cpython-ce418b448f431f2e62f0517f337f5b6762f4ae45.tar.bz2
Issue #14605: Stop having implicit entries for sys.meta_path.
ImportWarning is raised if sys.meta_path is found to be empty.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 2f42906..b88acc5 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -956,8 +956,9 @@ def _resolve_name(name, package, level):
def _find_module(name, path):
"""Find a module's loader."""
- meta_path = sys.meta_path + _IMPLICIT_META_PATH
- for finder in meta_path:
+ if not sys.meta_path:
+ _warnings.warn('sys.meta_path is empty', ImportWarning)
+ for finder in sys.meta_path:
loader = finder.find_module(name, path)
if loader is not None:
# The parent import may have already imported this module.
@@ -986,8 +987,6 @@ def _sanity_check(name, package, level):
raise ValueError("Empty module name")
-_IMPLICIT_META_PATH = [BuiltinImporter, FrozenImporter, PathFinder]
-
_ERR_MSG = 'No module named {!r}'
def _find_and_load(name, import_):
@@ -1195,3 +1194,4 @@ def _install(sys_module, _imp_module):
(SourcelessFileLoader, _suffix_list(2), True)]
sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders),
_imp.NullImporter])
+ sys.meta_path.extend([BuiltinImporter, FrozenImporter, PathFinder])