|
15 | 15 | import abc
|
16 | 16 | import warnings
|
17 | 17 |
|
18 |
| -# for compatibility with Python 3.10 |
19 |
| -from .resources.abc import ResourceReader, Traversable, TraversableResources |
| 18 | +from .resources import abc as _resources_abc |
20 | 19 |
|
21 | 20 |
|
22 | 21 | __all__ = [
|
23 | 22 | 'Loader', 'Finder', 'MetaPathFinder', 'PathEntryFinder',
|
24 | 23 | 'ResourceLoader', 'InspectLoader', 'ExecutionLoader',
|
25 | 24 | 'FileLoader', 'SourceLoader',
|
26 |
| - |
27 |
| - # for compatibility with Python 3.10 |
28 |
| - 'ResourceReader', 'Traversable', 'TraversableResources', |
29 | 25 | ]
|
30 | 26 |
|
31 | 27 |
|
| 28 | +def __getattr__(name, canonical=_resources_abc): |
| 29 | + """ |
| 30 | + For backwards compatibility, continue to make names |
| 31 | + from canonical available through this module. |
| 32 | + """ |
| 33 | + if name in canonical.__all__: |
| 34 | + obj = getattr(canonical, name) |
| 35 | + import warnings |
| 36 | + warnings.warn( |
| 37 | + f"Using or importing the ABCs from {__name__!r} instead " |
| 38 | + f"of from {canonical.__name__!r} is deprecated since " |
| 39 | + "Python 3.11, and in 3.13 it will stop working", |
| 40 | + DeprecationWarning, |
| 41 | + stacklevel=2, |
| 42 | + ) |
| 43 | + globals()[name] = obj |
| 44 | + return obj |
| 45 | + raise AttributeError(f'module {__name__!r} has no attribute {name!r}') |
| 46 | + |
| 47 | + |
32 | 48 | def _register(abstract_cls, *classes):
|
33 | 49 | for cls in classes:
|
34 | 50 | abstract_cls.register(cls)
|
|
0 commit comments