From a1ea254dfa2ce9e130e71e9d0baa4c89b2214ce6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Dec 2021 12:53:43 -0500 Subject: Expand compatibility shims with documentation and explicit imports. --- Lib/importlib/abc.py | 10 +++++++--- Lib/importlib/readers.py | 13 ++++++++++++- Lib/importlib/simple.py | 15 ++++++++++++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py index 2a4841a16a..3fa151f390 100644 --- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -12,16 +12,20 @@ try: except ImportError: _frozen_importlib_external = _bootstrap_external from ._abc import Loader -from .resources.abc import ResourceReader, Traversable, TraversableResources import abc import warnings +# for compatibility with Python 3.10 +from .resources.abc import ResourceReader, Traversable, TraversableResources + __all__ = [ 'Loader', 'Finder', 'MetaPathFinder', 'PathEntryFinder', 'ResourceLoader', 'InspectLoader', 'ExecutionLoader', - 'FileLoader', 'SourceLoader', 'ResourceReader', 'Traversable', - 'TraversableResources', + 'FileLoader', 'SourceLoader', + + # for compatibility with Python 3.10 + 'ResourceReader', 'Traversable', 'TraversableResources', ] diff --git a/Lib/importlib/readers.py b/Lib/importlib/readers.py index 276157400e..df7fb92e5c 100644 --- a/Lib/importlib/readers.py +++ b/Lib/importlib/readers.py @@ -1 +1,12 @@ -from .resources.readers import * +""" +Compatibility shim for .resources.readers as found on Python 3.10. + +Consumers that can rely on Python 3.11 should use the other +module directly. +""" + +from .resources.readers import ( + FileReader, ZipReader, MultiplexedPath, NamespaceReader, +) + +__all__ = ['FileReader', 'ZipReader', 'MultiplexedPath', 'NamespaceReader'] diff --git a/Lib/importlib/simple.py b/Lib/importlib/simple.py index 44ac2c0664..845bb90364 100644 --- a/Lib/importlib/simple.py +++ b/Lib/importlib/simple.py @@ -1 +1,14 @@ -from .resources.simple import * +""" +Compatibility shim for .resources.simple as found on Python 3.10. + +Consumers that can rely on Python 3.11 should use the other +module directly. +""" + +from .resources.simple import ( + SimpleReader, ResourceHandle, ResourceContainer, TraversableReader, +) + +__all__ = [ + 'SimpleReader', 'ResourceHandle', 'ResourceContainer', 'TraversableReader', +] -- cgit v1.2.1