Add a Traversable.read_text()errors parameter#321
Merged
+161 −14
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
Traversableprotocol and concrete methods to be tested.This additional infrastructure demonstrates the original issue,
but also highlights that the
Traversable.joinpath()concrete methodraises
TraversalErrorwhich is not getting caught in several places.Catch
TraversalError, raised byTraversable.joinpath().Exercising the
Traversableprotocol'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
TypeErrorlurking in theread_text()functional API.importlib_resources.read_text()calls theTraversable.read_text()concrete method with an
errorsargument that doesn't exist in themethod signature, resulting in an
TypeError.This is resolved by adding an
errorsparameter toTraversable.read_text().Fixespython/cpython#127012