Skip to content

Commit 3503c8b

Browse files
barneygalejaraco
authored andcommitted
Use Windows path rules to parse ZipFile.filename on Windows
Fixes #133
1 parent a706776 commit 3503c8b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

newsfragments/133.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use Windows path rules to parse ``ZipFile.filename`` on Windows

tests/test_path.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ def test_root_name(self, alpharep):
356356
"""
357357
The name of the root should be the name of the zipfile
358358
"""
359+
alpharep = self.zipfile_ondisk(alpharep)
359360
root = zipfile.Path(alpharep)
360361
assert root.name == 'alpharep.zip' == root.filename.name
361362

@@ -412,6 +413,7 @@ def test_stem(self, alpharep):
412413
"""
413414
The final path component, without its suffix
414415
"""
416+
alpharep = self.zipfile_ondisk(alpharep)
415417
root = zipfile.Path(alpharep)
416418
assert root.stem == 'alpharep' == root.filename.stem
417419

zipp/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ def open(self, mode='r', *args, pwd=None, **kwargs):
356356
return io.TextIOWrapper(stream, encoding, *args, **kwargs)
357357

358358
def _base(self):
359-
return pathlib.PurePosixPath(self.at or self.root.filename)
359+
if self.at:
360+
return pathlib.PurePosixPath(self.at)
361+
else:
362+
return pathlib.PurePath(self.root.filename)
360363

361364
@property
362365
def name(self):

0 commit comments

Comments
 (0)