Skip to content

Commit d15e958

Browse files
authored
[3.11] gh-101566: Sync with zipp 3.14. (GH-102018). (GH-102090)
(cherry picked from commit 36854bb) Backport of bugfix only. Automerge-Triggered-By: GH:jaraco
1 parent 62c0327 commit d15e958

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

Lib/test/test_zipfile.py

+11
Original file line numberDiff line numberDiff line change
@@ -3339,6 +3339,17 @@ def test_inheritance(self, alpharep):
33393339
file = cls(alpharep).joinpath('some dir').parent
33403340
assert isinstance(file, cls)
33413341

3342+
@pass_alpharep
3343+
def test_extract_orig_with_implied_dirs(self, alpharep):
3344+
"""
3345+
A zip file wrapped in a Path should extract even with implied dirs.
3346+
"""
3347+
source_path = self.zipfile_ondisk(alpharep)
3348+
zf = zipfile.ZipFile(source_path)
3349+
# wrap the zipfile for its side effect
3350+
zipfile.Path(zf)
3351+
zf.extractall(source_path.parent)
3352+
33423353

33433354
class EncodedMetadataTests(unittest.TestCase):
33443355
file_names = ['\u4e00', '\u4e8c', '\u4e09'] # Han 'one', 'two', 'three'

Lib/zipfile.py

+11
Original file line numberDiff line numberDiff line change
@@ -2250,6 +2250,17 @@ def resolve_dir(self, name):
22502250
dir_match = name not in names and dirname in names
22512251
return dirname if dir_match else name
22522252

2253+
def getinfo(self, name):
2254+
"""
2255+
Supplement getinfo for implied dirs.
2256+
"""
2257+
try:
2258+
return super().getinfo(name)
2259+
except KeyError:
2260+
if not name.endswith('/') or name not in self._name_set():
2261+
raise
2262+
return ZipInfo(filename=name)
2263+
22532264
@classmethod
22542265
def make(cls, source):
22552266
"""
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)