summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/abc.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/importlib/abc.py')
-rw-r--r--Lib/importlib/abc.py92
1 files changed, 1 insertions, 91 deletions
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
index 8fa9a0f..b56fa94 100644
--- a/Lib/importlib/abc.py
+++ b/Lib/importlib/abc.py
@@ -19,7 +19,7 @@ from .resources import abc as _resources_abc
__all__ = [
- 'Loader', 'Finder', 'MetaPathFinder', 'PathEntryFinder',
+ 'Loader', 'MetaPathFinder', 'PathEntryFinder',
'ResourceLoader', 'InspectLoader', 'ExecutionLoader',
'FileLoader', 'SourceLoader',
]
@@ -49,38 +49,6 @@ def _register(abstract_cls, *classes):
abstract_cls.register(frozen_cls)
-class Finder(metaclass=abc.ABCMeta):
-
- """Legacy abstract base class for import finders.
-
- It may be subclassed for compatibility with legacy third party
- reimplementations of the import system. Otherwise, finder
- implementations should derive from the more specific MetaPathFinder
- or PathEntryFinder ABCs.
-
- Deprecated since Python 3.3
- """
-
- def __init__(self):
- warnings.warn("the Finder ABC is deprecated and "
- "slated for removal in Python 3.12; use MetaPathFinder "
- "or PathEntryFinder instead",
- DeprecationWarning)
-
- @abc.abstractmethod
- def find_module(self, fullname, path=None):
- """An abstract method that should find a module.
- The fullname is a str and the optional path is a str or None.
- Returns a Loader object or None.
- """
- warnings.warn("importlib.abc.Finder along with its find_module() "
- "method are deprecated and "
- "slated for removal in Python 3.12; use "
- "MetaPathFinder.find_spec() or "
- "PathEntryFinder.find_spec() instead",
- DeprecationWarning)
-
-
class MetaPathFinder(metaclass=abc.ABCMeta):
"""Abstract base class for import finders on sys.meta_path."""
@@ -88,27 +56,6 @@ class MetaPathFinder(metaclass=abc.ABCMeta):
# We don't define find_spec() here since that would break
# hasattr checks we do to support backward compatibility.
- def find_module(self, fullname, path):
- """Return a loader for the module.
-
- If no module is found, return None. The fullname is a str and
- the path is a list of strings or None.
-
- This method is deprecated since Python 3.4 in favor of
- finder.find_spec(). If find_spec() exists then backwards-compatible
- functionality is provided for this method.
-
- """
- warnings.warn("MetaPathFinder.find_module() is deprecated since Python "
- "3.4 in favor of MetaPathFinder.find_spec() and is "
- "slated for removal in Python 3.12",
- DeprecationWarning,
- stacklevel=2)
- if not hasattr(self, 'find_spec'):
- return None
- found = self.find_spec(fullname, path)
- return found.loader if found is not None else None
-
def invalidate_caches(self):
"""An optional method for clearing the finder's cache, if any.
This method is used by importlib.invalidate_caches().
@@ -122,43 +69,6 @@ class PathEntryFinder(metaclass=abc.ABCMeta):
"""Abstract base class for path entry finders used by PathFinder."""
- # We don't define find_spec() here since that would break
- # hasattr checks we do to support backward compatibility.
-
- def find_loader(self, fullname):
- """Return (loader, namespace portion) for the path entry.
-
- The fullname is a str. The namespace portion is a sequence of
- path entries contributing to part of a namespace package. The
- sequence may be empty. If loader is not None, the portion will
- be ignored.
-
- The portion will be discarded if another path entry finder
- locates the module as a normal module or package.
-
- This method is deprecated since Python 3.4 in favor of
- finder.find_spec(). If find_spec() is provided than backwards-compatible
- functionality is provided.
- """
- warnings.warn("PathEntryFinder.find_loader() is deprecated since Python "
- "3.4 in favor of PathEntryFinder.find_spec() "
- "(available since 3.4)",
- DeprecationWarning,
- stacklevel=2)
- if not hasattr(self, 'find_spec'):
- return None, []
- found = self.find_spec(fullname)
- if found is not None:
- if not found.submodule_search_locations:
- portions = []
- else:
- portions = found.submodule_search_locations
- return found.loader, portions
- else:
- return None, []
-
- find_module = _bootstrap_external._find_module_shim
-
def invalidate_caches(self):
"""An optional method for clearing the finder's cache, if any.
This method is used by PathFinder.invalidate_caches().