Skip to content

Commit 509ac17

Browse files
committed
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 ec22ea9 commit 509ac17

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
@@ -80,11 +80,13 @@ def read_bytes(self) -> bytes:
8080
with self.open('rb') as strm:
8181
return strm.read()
8282

83-
def read_text(self, encoding: Optional[str] = None) -> str:
83+
def read_text(
84+
self, encoding: Optional[str] = None, errors: Optional[str] = None
85+
) -> str:
8486
"""
8587
Read contents of self as text
8688
"""
87-
with self.open(encoding=encoding) as strm:
89+
with self.open(encoding=encoding, errors=errors) as strm:
8890
return strm.read()
8991

9092
@abc.abstractmethod

0 commit comments

Comments
 (0)