Skip to content

Commit fc4df51

Browse files
committed
Rely on read_text and read_bytes from located paths.
1 parent 6202787 commit fc4df51

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

importlib_metadata/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,10 @@ class PackagePath(pathlib.PurePosixPath):
315315
dist: "Distribution"
316316

317317
def read_text(self, encoding: str = 'utf-8') -> str: # type: ignore[override]
318-
with self.locate().open(encoding=encoding) as stream:
319-
return stream.read()
318+
return self.locate().read_text(encoding=encoding)
320319

321320
def read_binary(self) -> bytes:
322-
with self.locate().open('rb') as stream:
323-
return stream.read()
321+
return self.locate().read_bytes()
324322

325323
def locate(self) -> pathlib.Path:
326324
"""Return a path-like object for this path"""

0 commit comments

Comments
 (0)