Skip to content

Commit 71848c9

Browse files
authored
gh-93963: Officially deprecate abcs and warn about their usage. (GH-93965)
Fixes #93963 Automerge-Triggered-By: GH:jaraco
1 parent b296c74 commit 71848c9

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Lib/importlib/abc.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,29 @@
1515
import abc
1616
import warnings
1717

18-
# for compatibility with Python 3.10
19-
from .resources.abc import ResourceReader, Traversable, TraversableResources
18+
from .resources import abc as _resources_abc
2019

2120

2221
__all__ = [
2322
'Loader', 'Finder', 'MetaPathFinder', 'PathEntryFinder',
2423
'ResourceLoader', 'InspectLoader', 'ExecutionLoader',
2524
'FileLoader', 'SourceLoader',
26-
27-
# for compatibility with Python 3.10
28-
'ResourceReader', 'Traversable', 'TraversableResources',
2925
]
3026

3127

28+
def __getattr__(name):
29+
"""
30+
For backwards compatibility, continue to make names
31+
from _resources_abc available through this module. #93963
32+
"""
33+
if name in _resources_abc.__all__:
34+
obj = getattr(_resources_abc, name)
35+
warnings._deprecated(f"{__name__}.{name}", remove=(3, 14))
36+
globals()[name] = obj
37+
return obj
38+
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
39+
40+
3241
def _register(abstract_cls, *classes):
3342
for cls in classes:
3443
abstract_cls.register(cls)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Officially deprecate from ``importlib.abc`` classes moved to
2+
``importlib.resources.abc``.

0 commit comments

Comments
 (0)