ZipFile.mkdir(ZipInfo.from_file(...)) CRC AttributeError
オープン
まだ誰も着手していません。
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
Adding a directory entry to a zip file on the basis of a ZipInfo object (to pick up metadata) fails because ZipFile evidently expects the object to have a CRC attribute even though it's a directory rather than a file. I can work around this bug by storing the ZipInfo in a variable and giving it a nominal CRC (namely 0), but that shouldn't be necessary. Specifically,
import os
import zipfile
with zipfile.ZipFile("bug.zip", mode = "w") as z:
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
- gh-119108
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Lib/zipfile/init.py、特に ZipFile.mkdir と ZipInfo.FileHeader から始め、提供された ZipInfo.from_file('usr') の例を再現してください。ディレクトリエントリに関する zipfile のテストを確認し、この呼び出しのカバレッジを追加してください。例が AttributeError なしで完了し、関連するテストが通れば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100