diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2023-02-20 23:21:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-20 23:21:48 (GMT) |
commit | 7bb41d9d5d2f0be30fd367fd085bb307db1a1ca3 (patch) | |
tree | d45736c1f32fb11725ba59b22c8aeef3ffafce5c | |
parent | 95f4e2ca03efbe020ae590108c022219008bbaf3 (diff) | |
download | cpython-7bb41d9d5d2f0be30fd367fd085bb307db1a1ca3.zip cpython-7bb41d9d5d2f0be30fd367fd085bb307db1a1ca3.tar.gz cpython-7bb41d9d5d2f0be30fd367fd085bb307db1a1ca3.tar.bz2 |
[3.10] gh-101566: Sync with zipp 3.14. (GH-102018). (GH-102091)
(cherry picked from commit 36854bbb240e417c0df6f0014924fcc899388186)
Includes the bugfix only.
Automerge-Triggered-By: GH:jaraco
-rw-r--r-- | Lib/test/test_zipfile.py | 11 | ||||
-rw-r--r-- | Lib/zipfile.py | 11 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2023-02-17-20-24-15.gh-issue-101566.FjgWBt.rst | 3 |
3 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index cf40412..c7371f5 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -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() diff --git a/Lib/zipfile.py b/Lib/zipfile.py index dc4eb38..23e4ee4 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -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 index 0000000..f0c0c24 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-02-17-20-24-15.gh-issue-101566.FjgWBt.rst @@ -0,0 +1,3 @@ +In zipfile, apply +fix for extractall on the underlying zipfile after being wrapped in +``Path``. |