Add a Traversable.read_text()
errors
parameter
#321
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the following changes, in three commits:
Demonstrate
importlib.abc.Traversable.read_text()
incompatible withimportlib.resources._functional.read_text()
usage (Python 3.13) cpython#127012.This adds an in-memory finder, loader, and traversable implementation,
which allows the
Traversable
protocol and concrete methods to be tested.This additional infrastructure demonstrates the original issue,
but also highlights that the
Traversable.joinpath()
concrete methodraises
TraversalError
which is not getting caught in several places.Catch
TraversalError
, raised byTraversable.joinpath()
.Exercising the
Traversable
protocol's concrete methodshas highlighted that
.joinpath()
raisesTraversalError
,which needs to be caught in several places.
This is primarily resolved within the test suite,
but implicates the
is_resource()
function as well.Resolve a
TypeError
lurking in theread_text()
functional API.importlib_resources.read_text()
calls theTraversable.read_text()
concrete method with an
errors
argument that doesn't exist in themethod signature, resulting in an
TypeError
.This is resolved by adding an
errors
parameter toTraversable.read_text()
.Fixes python/cpython#127012
Note
This PR includes the unrelated fixes posted in #320, which allows the test suite (locally, at least) to pass.