From: Jason R. Coombs Date: Thu, 5 Sep 2024 09:15:03 +0000 (-0400) Subject: [3.10] gh-123693: Use platform-agnostic semantics when processing zipfile.Path.name... X-Git-Tag: v3.10.15~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4633177a089e9debbca2b4c0ad6c910fd37b36d0;p=thirdparty%2FPython%2Fcpython.git [3.10] gh-123693: Use platform-agnostic semantics when processing zipfile.Path.name. (#123694) Applies changes from zipp 3.20.1 and jaraco/zippGH-124 (cherry picked from commit 2231286d78d328c2f575e0b05b16fe447d1656d6) (cherry picked from commit 17b77bb) Co-authored-by: Jason R. Coombs --- diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 33e5dfc61c5e..b4f71a8b3f64 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -5,7 +5,6 @@ import io import itertools import os import pathlib -import platform import posixpath import string import struct @@ -3299,7 +3298,6 @@ with zipfile.ZipFile(io.BytesIO(), "w") as zf: assert list(map(str, root.iterdir())) == ['../'] assert root.joinpath('..').joinpath('parent.txt').read_bytes() == b'content' - @unittest.skipIf(platform.system() == "Windows", "GH-123693") def test_unsupported_names(self): """ Path segments with special characters are readable. @@ -3320,7 +3318,6 @@ with zipfile.ZipFile(io.BytesIO(), "w") as zf: assert item.name == 'V: NMS.flac', item.name assert root.joinpath('V: NMS.flac').read_bytes() == b"fLaC..." - @unittest.skipIf(platform.system() == "Windows", "GH-123693") def test_backslash_not_separator(self): """ In a zip file, backslashes are not separators. diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 9b66a9f054dc..4cd44fb1e4a8 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -2387,7 +2387,7 @@ class Path: @property def name(self): - return pathlib.Path(self.at).name or self.filename.name + return pathlib.PurePosixPath(self.at).name or self.filename.name @property def filename(self): diff --git a/Misc/NEWS.d/next/Library/2024-09-04-14-05-02.gh-issue-123693.dNW1IF.rst b/Misc/NEWS.d/next/Library/2024-09-04-14-05-02.gh-issue-123693.dNW1IF.rst new file mode 100644 index 000000000000..e9ad02de8fe6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-09-04-14-05-02.gh-issue-123693.dNW1IF.rst @@ -0,0 +1 @@ +Use platform-agnostic behavior when computing ``zipfile.Path.name``.