diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-06-14 12:12:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-14 12:12:20 (GMT) |
commit | 8a3469047c3c7b68f434ed244ef3ae4292dd8cbc (patch) | |
tree | 429e44857f3333f68d06d0d72c176eddf3319e22 | |
parent | 83cd968f5cc59ad60b665080087f50fefac17a07 (diff) | |
download | cpython-8a3469047c3c7b68f434ed244ef3ae4292dd8cbc.zip cpython-8a3469047c3c7b68f434ed244ef3ae4292dd8cbc.tar.gz cpython-8a3469047c3c7b68f434ed244ef3ae4292dd8cbc.tar.bz2 |
[3.9] bpo-40924: Remove protocol for supplying Traversable objects from loaders (GH-20820)
Remove protocol that loaders can present a files method as found in importlib_resources 1.3-1.6 (added in Python 3.8b1).
-rw-r--r-- | Doc/library/importlib.rst | 3 | ||||
-rw-r--r-- | Lib/importlib/_common.py | 12 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-06-11-23-41-50.bpo-40924.m17Fkm.rst | 1 |
3 files changed, 2 insertions, 14 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index 99bfeac..201f813 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -813,9 +813,6 @@ ABC hierarchy:: methods. Therefore, any loader supplying TraversableReader also supplies ResourceReader. - Loaders that wish to support resource reading are expected to - implement this interface. - .. versionadded:: 3.9 diff --git a/Lib/importlib/_common.py b/Lib/importlib/_common.py index ba7cbac..c1204f0 100644 --- a/Lib/importlib/_common.py +++ b/Lib/importlib/_common.py @@ -11,17 +11,7 @@ def from_package(package): Return a Traversable object for the given package. """ - spec = package.__spec__ - return from_traversable_resources(spec) or fallback_resources(spec) - - -def from_traversable_resources(spec): - """ - If the spec.loader implements TraversableResources, - directly or implicitly, it will have a ``files()`` method. - """ - with contextlib.suppress(AttributeError): - return spec.loader.files() + return fallback_resources(package.__spec__) def fallback_resources(spec): diff --git a/Misc/NEWS.d/next/Library/2020-06-11-23-41-50.bpo-40924.m17Fkm.rst b/Misc/NEWS.d/next/Library/2020-06-11-23-41-50.bpo-40924.m17Fkm.rst new file mode 100644 index 0000000..9621dd6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-06-11-23-41-50.bpo-40924.m17Fkm.rst @@ -0,0 +1 @@ +Removed support for loaders implementing .files and supplying TraversableResources.
\ No newline at end of file |