]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-93963: Officially deprecate abcs and warn about their usage. (GH-93965)
authorJason R. Coombs <jaraco@jaraco.com>
Sun, 3 Jul 2022 19:17:27 +0000 (15:17 -0400)
committerGitHub <noreply@github.com>
Sun, 3 Jul 2022 19:17:27 +0000 (12:17 -0700)
Fixes #93963

Automerge-Triggered-By: GH:jaraco
Lib/importlib/abc.py
Misc/NEWS.d/next/Library/2022-06-17-16-00-55.gh-issue-93963.8YYZ-2.rst [new file with mode: 0644]

index 3fa151f390ba7ca29a6f854fd631bf21a98ce667..8fa9a0f3bc1e4b9c77fb845dc24123d7c165c1c9 100644 (file)
@@ -15,20 +15,29 @@ from ._abc import Loader
 import abc
 import warnings
 
-# for compatibility with Python 3.10
-from .resources.abc import ResourceReader, Traversable, TraversableResources
+from .resources import abc as _resources_abc
 
 
 __all__ = [
     'Loader', 'Finder', 'MetaPathFinder', 'PathEntryFinder',
     'ResourceLoader', 'InspectLoader', 'ExecutionLoader',
     'FileLoader', 'SourceLoader',
-
-    # for compatibility with Python 3.10
-    'ResourceReader', 'Traversable', 'TraversableResources',
 ]
 
 
+def __getattr__(name):
+    """
+    For backwards compatibility, continue to make names
+    from _resources_abc available through this module. #93963
+    """
+    if name in _resources_abc.__all__:
+        obj = getattr(_resources_abc, name)
+        warnings._deprecated(f"{__name__}.{name}", remove=(3, 14))
+        globals()[name] = obj
+        return obj
+    raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
+
+
 def _register(abstract_cls, *classes):
     for cls in classes:
         abstract_cls.register(cls)
diff --git a/Misc/NEWS.d/next/Library/2022-06-17-16-00-55.gh-issue-93963.8YYZ-2.rst b/Misc/NEWS.d/next/Library/2022-06-17-16-00-55.gh-issue-93963.8YYZ-2.rst
new file mode 100644 (file)
index 0000000..0973982
--- /dev/null
@@ -0,0 +1,2 @@
+Officially deprecate from ``importlib.abc`` classes moved to
+``importlib.resources.abc``.