-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Traversable.read_text()
errors
parameter
#321
Add a Traversable.read_text()
errors
parameter
#321
Conversation
Traversable.readtext()
errors
parameterTraversable.read_text()
errors
parameter
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 python/cpython#127012, but also highlights that the `Traversable.joinpath()` concrete method raises `TraversalError` which is not getting caught in several places.
Exercising the `Traversable` protocol's concrete methods has highlighted that `.joinpath()` raises `TraversalError`, which needs to be caught in several places. This is primarily resolved within the test suite, but implicates the `is_resource()` function as well.
`importlib_resources.read_text()` calls the `Traversable.read_text()` concrete method with an `errors` argument that doesn't exist in the method signature, resulting in an `TypeError`. This is resolved by adding an `errors` parameter to `Traversable.read_text()`. Fixes python/cpython#127012
509ac17
to
d001110
Compare
I've force-pushed the three commits after rebasing on main. Now tests are failing because I've re-enabled mypy checks (that were previously disabled).
|
In the latest commit, I consolidated the repeated pattern of resolving a fullname from the fixtures, and this incidentally masks the type ambiguity. |
30bc726
to
72d550d
Compare
Thanks again for this PR. The work you did here was exemplary - it was clear, understandable, complete, and directly addressed the issue. Bravo. |
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