Skip to content

Commit d7a1aec

Browse files
committed
Still rely on joinpath while deferring path construction until much later.
1 parent a2ccf3a commit d7a1aec

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

importlib_metadata/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,22 @@ class FastPath:
392392
children.
393393
"""
394394

395-
path_type = pathlib.Path
396-
397395
def __init__(self, root):
398396
self.root = root
399397

398+
def joinpath(self, child):
399+
return pathlib.Path(self.root, child)
400+
400401
def children(self):
401402
with suppress(Exception):
402403
yield from os.listdir(self.root or '')
403404
with suppress(Exception):
404405
yield from self.zip_children()
405406

406407
def zip_children(self):
407-
with zipfile.ZipFile(self.root) as zf:
408-
names = zf.namelist()
409-
self.path_type = zipp.Path
408+
zip_path = zipp.Path(self.root)
409+
names = zip_path.root.namelist()
410+
self.joinpath = zip_path.joinpath
410411

411412
return (
412413
os.path.split(child)[0]
@@ -429,7 +430,7 @@ def search(self, name):
429430
and n_low.endswith(name.suffixes)
430431
# legacy case:
431432
or self.is_egg(name) and n_low == 'egg-info'):
432-
yield self.path_type(self.root, child)
433+
yield self.joinpath(child)
433434

434435

435436
class Prepared:

0 commit comments

Comments
 (0)