Skip to content

Path.name returns the absolute file path on Windows #133

@hoefling

Description

@hoefling

Steps to reproduce (used zipp==3.21.0):

import pathlib
import tempfile
import zipfile


tmp = pathlib.Path(tempfile.mkdtemp())
dummy = tmp / "dummy.zip"
with zipfile.ZipFile(dummy, "w") as file:
    file.writestr("spam.txt", "eggs")


import zipp


file = zipp.Path(dummy)
print(file.name)
print(file.stem)
print(str(file))

Output on Linux:

dummy.zip
dummy
/tmp/tmpufwzzke9/dummy.zip/

Output on Windows:

C:\Users\hoefling\AppData\Local\Temp\tmpkh18jxk7\dummy.zip
C:\Users\hoefling\AppData\Local\Temp\tmpkh18jxk7\dummy
C:\Users\hoefling\AppData\Local\Temp\tmpkh18jxk7\dummy.zip/

Is this a desired behaviour? BTW since python/cpython#106757 this is also the case in the stdlib's zipfile module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions