]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-106752: Sync with zipp 3.16.2 (GH-106757) (#106778)
authorJason R. Coombs <jaraco@jaraco.com>
Sat, 15 Jul 2023 14:15:38 +0000 (10:15 -0400)
committerGitHub <noreply@github.com>
Sat, 15 Jul 2023 14:15:38 +0000 (10:15 -0400)
* gh-106752: Sync with zipp 3.16.2 (#106757)

* gh-106752: Sync with zipp 3.16.2

* Add blurb

(cherry picked from commit 22980dc7c9dcec4b74fea815542601ef582c230e)

* [3.11] gh-106752: Sync with zipp 3.16.2 (GH-106757)

* gh-106752: Sync with zipp 3.16.2

* Add blurb.
(cherry picked from commit 22980dc7c9dcec4b74fea815542601ef582c230e)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* Remove Python 3.12 concerns from changelog.

Lib/test/test_zipfile.py
Lib/zipfile.py
Misc/NEWS.d/next/Library/2023-07-14-16-54-13.gh-issue-106752.BT1Yxw.rst [new file with mode: 0644]

index bb2c24c8c50c58eac0e074967080f40f5612c878..c8e0159765ec2c39fd61741d2dbbb8ac4aed744e 100644 (file)
@@ -3443,6 +3443,13 @@ with zipfile.ZipFile(io.BytesIO(), "w") as zf:
         e = root / '.hgrc'
         assert e.suffixes == []
 
+    @pass_alpharep
+    def test_suffix_no_filename(self, alpharep):
+        alpharep.filename = None
+        root = zipfile.Path(alpharep)
+        assert root.joinpath('example').suffix == ""
+        assert root.joinpath('example').suffixes == []
+
     @pass_alpharep
     def test_stem(self, alpharep):
         """
@@ -3460,6 +3467,8 @@ with zipfile.ZipFile(io.BytesIO(), "w") as zf:
         d = root / "d"
         assert d.stem == "d"
 
+        assert (root / ".gitignore").stem == ".gitignore"
+
     @pass_alpharep
     def test_root_parent(self, alpharep):
         root = zipfile.Path(alpharep)
index 1dec6a8b97bc4f98fd92d93aa2d91d3cf5831504..6189db5e3e420dd1f9d311580136079d188e6922 100644 (file)
@@ -2420,21 +2420,24 @@ class Path:
         encoding, args, kwargs = _extract_text_encoding(*args, **kwargs)
         return io.TextIOWrapper(stream, encoding, *args, **kwargs)
 
+    def _base(self):
+        return pathlib.PurePosixPath(self.at or self.root.filename)
+
     @property
     def name(self):
-        return pathlib.Path(self.at).name or self.filename.name
+        return self._base().name
 
     @property
     def suffix(self):
-        return pathlib.Path(self.at).suffix or self.filename.suffix
+        return self._base().suffix
 
     @property
     def suffixes(self):
-        return pathlib.Path(self.at).suffixes or self.filename.suffixes
+        return self._base().suffixes
 
     @property
     def stem(self):
-        return pathlib.Path(self.at).stem or self.filename.stem
+        return self._base().stem
 
     @property
     def filename(self):
diff --git a/Misc/NEWS.d/next/Library/2023-07-14-16-54-13.gh-issue-106752.BT1Yxw.rst b/Misc/NEWS.d/next/Library/2023-07-14-16-54-13.gh-issue-106752.BT1Yxw.rst
new file mode 100644 (file)
index 0000000..d36c97d
--- /dev/null
@@ -0,0 +1,3 @@
+Fixed several bug in zipfile.Path in
+``name``/``suffix``/``suffixes``/``stem`` operations when no filename is
+present and the Path is not at the root of the zipfile.