summaryrefslogtreecommitdiff
path: root/Lib/importlib/abc.py
diff options
context:
space:
mode:
authorMatthias Bussonnier <bussonniermatthias@gmail.com>2017-02-15 18:00:32 -0800
committerBrett Cannon <brettcannon@users.noreply.github.com>2017-02-15 18:00:32 -0800
commit1d4601c2c6952d03fc4dda2b041be9aa8713c0bc (patch)
tree0a2192efa8f0275e65a84ebef34fd060e72089c7 /Lib/importlib/abc.py
parent72dccde884d89586b0cafd990675b7e21720a81f (diff)
downloadcpython-git-1d4601c2c6952d03fc4dda2b041be9aa8713c0bc.tar.gz
bpo-29576: add explicit deprecation for importlib.abc.find_loader() and find_module() (GH-32)
Diffstat (limited to 'Lib/importlib/abc.py')
-rw-r--r--Lib/importlib/abc.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
index daff681e69..661bd76e07 100644
--- a/Lib/importlib/abc.py
+++ b/Lib/importlib/abc.py
@@ -13,6 +13,7 @@ try:
except ImportError as exc:
_frozen_importlib_external = _bootstrap_external
import abc
+import warnings
def _register(abstract_cls, *classes):
@@ -34,6 +35,8 @@ class Finder(metaclass=abc.ABCMeta):
reimplementations of the import system. Otherwise, finder
implementations should derive from the more specific MetaPathFinder
or PathEntryFinder ABCs.
+
+ Deprecated since Python 3.3
"""
@abc.abstractmethod
@@ -57,11 +60,16 @@ class MetaPathFinder(Finder):
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 in favor of finder.find_spec(). If find_spec()
- exists then backwards-compatible functionality is provided for this
- method.
+ 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()"
+ "(available since 3.4)",
+ DeprecationWarning,
+ stacklevel=2)
if not hasattr(self, 'find_spec'):
return None
found = self.find_spec(fullname, path)
@@ -94,10 +102,15 @@ class PathEntryFinder(Finder):
The portion will be discarded if another path entry finder
locates the module as a normal module or package.
- This method is deprecated in favor of finder.find_spec(). If find_spec()
- is provided than backwards-compatible functionality is provided.
-
+ 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)