Skip to content

Commit

Permalink
[3.10] gh-123693: Use platform-agnostic semantics when processing zip…
Browse files Browse the repository at this point in the history
…file.Path.name. (#123694)

Applies changes from zipp 3.20.1 and jaraco/zippGH-124
(cherry picked from commit 2231286)
(cherry picked from commit 17b77bb)

Co-authored-by: Jason R. Coombs <[email protected]>
  • Loading branch information
jaraco authored Sep 5, 2024
1 parent 0aa1ee2 commit 4633177
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
3 changes: 0 additions & 3 deletions Lib/test/test_zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import itertools
import os
import pathlib
import platform
import posixpath
import string
import struct
Expand Down Expand Up @@ -3299,7 +3298,6 @@ def test_malformed_paths(self):
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.
Expand All @@ -3320,7 +3318,6 @@ def test_unsupported_names(self):
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.
Expand Down
2 changes: 1 addition & 1 deletion Lib/zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,7 @@ def open(self, mode='r', *args, pwd=None, **kwargs):

@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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use platform-agnostic behavior when computing ``zipfile.Path.name``.

0 comments on commit 4633177

Please sign in to comment.