Skip to content

Commit 7ffb276

Browse files
committed
[3.10] gh-101566: Sync with zipp 3.14. (GH-102018).
(cherry picked from commit 36854bb) Co-authored-by: Jason R. Coombs <[email protected]>
1 parent 95f4e2c commit 7ffb276

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

Lib/test/test_zipfile.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,6 +3209,17 @@ def test_inheritance(self, alpharep):
32093209
file = cls(alpharep).joinpath('some dir').parent
32103210
assert isinstance(file, cls)
32113211

3212+
@pass_alpharep
3213+
def test_extract_orig_with_implied_dirs(self, alpharep):
3214+
"""
3215+
A zip file wrapped in a Path should extract even with implied dirs.
3216+
"""
3217+
source_path = self.zipfile_ondisk(alpharep)
3218+
zf = zipfile.ZipFile(source_path)
3219+
# wrap the zipfile for its side effect
3220+
zipfile.Path(zf)
3221+
zf.extractall(source_path.parent)
3222+
32123223

32133224
if __name__ == "__main__":
32143225
unittest.main()

Lib/zipfile.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,17 @@ def resolve_dir(self, name):
21972197
dir_match = name not in names and dirname in names
21982198
return dirname if dir_match else name
21992199

2200+
def getinfo(self, name):
2201+
"""
2202+
Supplement getinfo for implied dirs.
2203+
"""
2204+
try:
2205+
return super().getinfo(name)
2206+
except KeyError:
2207+
if not name.endswith('/') or name not in self._name_set():
2208+
raise
2209+
return ZipInfo(filename=name)
2210+
22002211
@classmethod
22012212
def make(cls, source):
22022213
"""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
In zipfile, apply
2+
fix for extractall on the underlying zipfile after being wrapped in
3+
``Path``.

0 commit comments

Comments
 (0)