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

ZipFile.mkdir(ZipInfo.from_file(...)) CRC AttributeError #119052

Open
Labels
stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@ucko

Description

@ucko

Bug report

Bug description:

Adding a directory entry to a zip file on the basis of aZipInfo object (to pick up metadata) fails becauseZipFile evidently expects the object to have aCRC attribute even though it's a directory rather than a file. I can work around this bug by storing theZipInfo in a variable and giving it a nominal CRC (namely 0), but that shouldn't be necessary. Specifically,

importosimportzipfilewithzipfile.ZipFile("bug.zip",mode="w")asz:os.chdir('/')z.mkdir(zipfile.ZipInfo.from_file('usr'))

fails:

  File ".../zipfile-bug.py", line 6, in <module>    z.mkdir(zipfile.ZipInfo.from_file('usr'))  File "/usr/lib/python3.12/zipfile/__init__.py", line 1935, in mkdir    self.fp.write(zinfo.FileHeader(False))                  ^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.12/zipfile/__init__.py", line 460, in FileHeader    CRC = self.CRC          ^^^^^^^^AttributeError: 'ZipInfo' object has no attribute 'CRC'

Could you please take a look?

Thanks!

CPython versions tested on:

3.11, 3.12, 3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp