summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/idlelib/EditorWindow.py8
-rw-r--r--Lib/pkgutil.py13
-rw-r--r--Lib/pyclbr.py9
3 files changed, 16 insertions, 14 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index eaf68cb..f855bc6 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -659,20 +659,20 @@ class EditorWindow(object):
return
# XXX Ought to insert current file's directory in front of path
try:
- loader = importlib.find_loader(name)
+ spec = importlib.find_spec(name)
except (ValueError, ImportError) as msg:
tkMessageBox.showerror("Import error", str(msg), parent=self.text)
return
- if loader is None:
+ if spec is None:
tkMessageBox.showerror("Import error", "module not found",
parent=self.text)
return
- if not isinstance(loader, importlib.abc.SourceLoader):
+ if not isinstance(spec.loader, importlib.abc.SourceLoader):
tkMessageBox.showerror("Import error", "not a source-based module",
parent=self.text)
return
try:
- file_path = loader.get_filename(name)
+ file_path = spec.loader.get_filename(name)
except AttributeError:
tkMessageBox.showerror("Import error",
"loader does not support get_filename",
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py
index 405a03d..7beae12 100644
--- a/Lib/pkgutil.py
+++ b/Lib/pkgutil.py
@@ -554,13 +554,14 @@ def extend_path(path, name):
finder = get_importer(dir)
if finder is not None:
+ portions = []
+ if hasattr(finder, 'find_spec'):
+ spec = finder.find_spec(final_name)
+ if spec is not None:
+ portions = spec.submodule_search_locations or []
# Is this finder PEP 420 compliant?
- if hasattr(finder, 'find_loader'):
- loader, portions = finder.find_loader(final_name)
- else:
- # No, no need to call it
- loader = None
- portions = []
+ elif hasattr(finder, 'find_loader'):
+ _, portions = finder.find_loader(final_name)
for portion in portions:
# XXX This may still add duplicate entries to path on
diff --git a/Lib/pyclbr.py b/Lib/pyclbr.py
index 9ec05ee..a8d2b1f 100644
--- a/Lib/pyclbr.py
+++ b/Lib/pyclbr.py
@@ -140,13 +140,14 @@ def _readmodule(module, path, inpackage=None):
search_path = path
else:
search_path = path + sys.path
- loader = importlib.find_loader(fullmodule, search_path)
- fname = loader.get_filename(fullmodule)
+ # XXX This will change once issue19944 lands.
+ spec = importlib.find_spec(fullmodule, search_path)
+ fname = spec.loader.get_filename(fullmodule)
_modules[fullmodule] = dict
- if loader.is_package(fullmodule):
+ if spec.loader.is_package(fullmodule):
dict['__path__'] = [os.path.dirname(fname)]
try:
- source = loader.get_source(fullmodule)
+ source = spec.loader.get_source(fullmodule)
if source is None:
return dict
except (AttributeError, ImportError):