diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2022-07-03 19:17:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-03 19:17:27 (GMT) |
commit | 71848c960927af801656026203371c41ad139b5a (patch) | |
tree | 5c2cd144f5cb78c00779e27d66bbc8042414adfa /Lib/importlib | |
parent | b296c7442be97600dc87819e885e037313883d8e (diff) | |
download | cpython-71848c960927af801656026203371c41ad139b5a.zip cpython-71848c960927af801656026203371c41ad139b5a.tar.gz cpython-71848c960927af801656026203371c41ad139b5a.tar.bz2 |
gh-93963: Officially deprecate abcs and warn about their usage. (GH-93965)
Fixes #93963
Automerge-Triggered-By: GH:jaraco
Diffstat (limited to 'Lib/importlib')
-rw-r--r-- | Lib/importlib/abc.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py index 3fa151f..8fa9a0f 100644 --- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -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) |