Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Zip extract fails for zips created with Windows #117084

Closed
Labels
type-bugAn unexpected behavior, bug, or error
@fliiiix

Description

@fliiiix

Bug report

Bug description:

importosfrompathlibimportPathfromzipfileimportZipFiledefunzip(target_file,destination=Path("/tmp/")):os.path.altsep="\\"withZipFile(target_file,"r")aszipf:zipf.extractall(path=destination)

Im building a small web service which allows user to upload zip files containing docshttps://github.com/docat-org/docat/blob/main/docat/docat/utils.py#L36 which get unpackt and hosted.

Because of that people create zip files on windows which we try to unpack on linux.
Which fails:

Traceback (most recent call last):  File "/home/user/Downloads/example/test.py", line 71, in <module>    unzip(Path("/home/user/Downloads/example/devdocu.zip"))  File "/home/user/Downloads/example/test.py", line 66, in unzip    zipf.extractall(path=destination)  File "/home/user/.asdf/installs/python/3.12.2/lib/python3.12/zipfile/__init__.py", line 1734, in extractall    self._extract_member(zipinfo, path, pwd)  File "/home/user/.asdf/installs/python/3.12.2/lib/python3.12/zipfile/__init__.py", line 1784, in _extract_member    os.makedirs(upperdirs)  File "<frozen os>", line 225, in makedirsNotADirectoryError: [Errno 20] Not a directory: '/tmp/DevDocu/articles/XXXX/FBRT/BackupAndRestore'

Unfortunately i can't share the actual zip file as it contains sensitive data.
Butzip -T thinks it is ok andunzip unpacks this zip without issues.

A bit of digging showed the problem as far as i can tell is inis_dir which claims that

self.filename='DevDocu\\articles\\XXX\\FBRT\\' is_dir? False

is a file and creates an empty file instead of a dir.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp