Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.10] gh-123693: Use platform-agnostic semantics when processing zipfile.Path.name. #123694

Merged
merged 10 commits into from
Sep 5, 2024
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``.
Loading