[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).
This commit is contained in:
Jason R. Coombs 2020-06-14 08:12:20 -04:00 committed by GitHub
parent 83cd968f5c
commit 8a3469047c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 14 deletions

View File

@ -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

View File

@ -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):

View File

@ -0,0 +1 @@
Removed support for loaders implementing .files and supplying TraversableResources.