Make it more obvious what things used in imp are snuck in through private APIs
diff --git a/Lib/imp.py b/Lib/imp.py
index 7d54e8a..d87dffc 100644
--- a/Lib/imp.py
+++ b/Lib/imp.py
@@ -16,11 +16,9 @@
# Platform doesn't support dynamic loading.
load_dynamic = None
-# Directly exposed by this module
-from importlib._bootstrap import cache_from_source, source_from_cache
+from importlib._bootstrap import (cache_from_source, source_from_cache,
+ SourcelessFileLoader, _ERR_MSG)
-
-from importlib import _bootstrap
from importlib import machinery
from importlib import util
import importlib
@@ -117,7 +115,7 @@
return super().get_data(path)
-class _LoadSourceCompatibility(_HackedGetData, _bootstrap.SourceFileLoader):
+class _LoadSourceCompatibility(_HackedGetData, machinery.SourceFileLoader):
"""Compatibility support for implementing load_source()."""
@@ -131,12 +129,11 @@
module = sys.modules[name]
# To allow reloading to potentially work, use a non-hacked loader which
# won't rely on a now-closed file object.
- module.__loader__ = _bootstrap.SourceFileLoader(name, pathname)
+ module.__loader__ = machinery.SourceFileLoader(name, pathname)
return module
-class _LoadCompiledCompatibility(_HackedGetData,
- _bootstrap.SourcelessFileLoader):
+class _LoadCompiledCompatibility(_HackedGetData, SourcelessFileLoader):
"""Compatibility support for implementing load_compiled()."""
@@ -150,7 +147,7 @@
module = sys.modules[name]
# To allow reloading to potentially work, use a non-hacked loader which
# won't rely on a now-closed file object.
- module.__loader__ = _bootstrap.SourcelessFileLoader(name, pathname)
+ module.__loader__ = SourcelessFileLoader(name, pathname)
return module
@@ -168,7 +165,7 @@
break
else:
raise ValueError('{!r} is not a package'.format(path))
- return _bootstrap.SourceFileLoader(name, path).load_module(name)
+ return machinery.SourceFileLoader(name, path).load_module(name)
def load_module(name, file, filename, details):
@@ -252,7 +249,7 @@
continue
break # Break out of outer loop when breaking out of inner loop.
else:
- raise ImportError(_bootstrap._ERR_MSG.format(name), name=name)
+ raise ImportError(_ERR_MSG.format(name), name=name)
encoding = None
if mode == 'U':