Skip to content

Commit d001110

Browse files
kurtmckeejaraco
authored andcommitted
Resolve a TypeError lurking in the read_text() functional API
`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
1 parent f10a2e9 commit d001110

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: importlib_resources/abc.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ def read_bytes(self) -> bytes:
9393
with self.open('rb') as strm:
9494
return strm.read()
9595

96-
def read_text(self, encoding: Optional[str] = None) -> str:
96+
def read_text(
97+
self, encoding: Optional[str] = None, errors: Optional[str] = None
98+
) -> str:
9799
"""
98100
Read contents of self as text
99101
"""
100-
with self.open(encoding=encoding) as strm:
102+
with self.open(encoding=encoding, errors=errors) as strm:
101103
return strm.read()
102104

103105
@abc.abstractmethod

0 commit comments

Comments
 (0)