Skip to content

Commit

Permalink
Override ZipFile.getinfo to supply a ZipInfo for implied dirs. Fixes p…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 5, 2023
1 parent 29b95e1 commit 6f8ae4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion tests/test_zipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ def test_extract_orig_with_implied_dirs(self, alpharep):
"""
A zip file wrapped in a Path should extract even with implied dirs.
"""
self.skipTest("Fails due to python-101566")
source_path = self.zipfile_ondisk(alpharep)
zf = zipfile.ZipFile(source_path)
# wrap the zipfile for its side effect
Expand Down
11 changes: 11 additions & 0 deletions zipp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ def resolve_dir(self, name):
dir_match = name not in names and dirname in names
return dirname if dir_match else name

def getinfo(self, name):
"""
Supplement getinfo for implied dirs.
"""
try:
return super(CompleteDirs, self).getinfo(name)
except KeyError:
if not name.endswith('/') or name not in self._name_set():
raise
return zipfile.ZipInfo(filename=name)

@classmethod
def make(cls, source):
"""
Expand Down

0 comments on commit 6f8ae4c

Please sign in to comment.