]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] gh-101566: Sync with zipp 3.14. (GH-102018). (GH-102091)
authorJason R. Coombs <jaraco@jaraco.com>
Mon, 20 Feb 2023 23:21:48 +0000 (18:21 -0500)
committerGitHub <noreply@github.com>
Mon, 20 Feb 2023 23:21:48 +0000 (15:21 -0800)
(cherry picked from commit 36854bbb240e417c0df6f0014924fcc899388186)

Includes the bugfix only.

Automerge-Triggered-By: GH:jaraco
Lib/test/test_zipfile.py
Lib/zipfile.py
Misc/NEWS.d/next/Library/2023-02-17-20-24-15.gh-issue-101566.FjgWBt.rst [new file with mode: 0644]

index cf40412f85266daf6dfcafc4877eba160b5fbf8a..c7371f59859ebcb2641f434e4b551046e48ace53 100644 (file)
@@ -3209,6 +3209,17 @@ with zipfile.ZipFile(io.BytesIO(), "w") as zf:
             file = cls(alpharep).joinpath('some dir').parent
             assert isinstance(file, cls)
 
+    @pass_alpharep
+    def test_extract_orig_with_implied_dirs(self, alpharep):
+        """
+        A zip file wrapped in a Path should extract even with implied dirs.
+        """
+        source_path = self.zipfile_ondisk(alpharep)
+        zf = zipfile.ZipFile(source_path)
+        # wrap the zipfile for its side effect
+        zipfile.Path(zf)
+        zf.extractall(source_path.parent)
+
 
 if __name__ == "__main__":
     unittest.main()
index dc4eb38e3a90255ccc28d146a683743f61af810b..23e4ee42d4d9604ef7a7d6f3080eb43048cfb47b 100644 (file)
@@ -2197,6 +2197,17 @@ class CompleteDirs(ZipFile):
         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().getinfo(name)
+        except KeyError:
+            if not name.endswith('/') or name not in self._name_set():
+                raise
+            return ZipInfo(filename=name)
+
     @classmethod
     def make(cls, source):
         """
diff --git a/Misc/NEWS.d/next/Library/2023-02-17-20-24-15.gh-issue-101566.FjgWBt.rst b/Misc/NEWS.d/next/Library/2023-02-17-20-24-15.gh-issue-101566.FjgWBt.rst
new file mode 100644 (file)
index 0000000..f0c0c24
--- /dev/null
@@ -0,0 +1,3 @@
+In zipfile, apply
+fix for extractall on the underlying zipfile after being wrapped in
+``Path``.