diff options
author | Brett Cannon <brett@python.org> | 2021-04-06 15:56:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 15:56:57 (GMT) |
commit | 57c6cb5100d19a0e0218c77d887c3c239c9ce435 (patch) | |
tree | 8e193c0bc12f476821639c8363d280ef9d604271 /Lib/importlib/abc.py | |
parent | efccff9ac84009ef48e8cb22548ce80940f76533 (diff) | |
download | cpython-57c6cb5100d19a0e0218c77d887c3c239c9ce435.zip cpython-57c6cb5100d19a0e0218c77d887c3c239c9ce435.tar.gz cpython-57c6cb5100d19a0e0218c77d887c3c239c9ce435.tar.bz2 |
bpo-42135: Deprecate implementations of find_module() and find_loader() (GH-25169)
Diffstat (limited to 'Lib/importlib/abc.py')
-rw-r--r-- | Lib/importlib/abc.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py index 4be51e2..0b4a3f8 100644 --- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -41,15 +41,27 @@ class Finder(metaclass=abc.ABCMeta): 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(Finder): +class MetaPathFinder(metaclass=abc.ABCMeta): """Abstract base class for import finders on sys.meta_path.""" @@ -68,8 +80,8 @@ class MetaPathFinder(Finder): """ warnings.warn("MetaPathFinder.find_module() is deprecated since Python " - "3.4 in favor of MetaPathFinder.find_spec() " - "(available since 3.4)", + "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'): @@ -86,7 +98,7 @@ _register(MetaPathFinder, machinery.BuiltinImporter, machinery.FrozenImporter, machinery.PathFinder, machinery.WindowsRegistryFinder) -class PathEntryFinder(Finder): +class PathEntryFinder(metaclass=abc.ABCMeta): """Abstract base class for path entry finders used by PathFinder.""" |