zipfile.ZipFile fails to read zstd-compressed file consisting of multiple frames
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
I have a ZIP file archive.zip that contains a file data.npy. This file is compressed with zstd, consisting of two zstd frames. When I try to read this in with zipfile, I get a BadZipFile: Bad CRC-32 for file 'data.npy' error.
import zipfile
with zipfile.ZipFile("archive.zip", "r") as z:
with z.open("data.npy", "r") as f:
data = f.read() # -> BadZipFile: Bad CRC-32 ...
The error is a red herring, though: When I disable CRC checking, there is no exception thrown, but the data read is in fact only the data from the first zstd frame. The second frame gets ignored completely (and thus the checksum is wrong).
import zipfile
with zipfile.ZipFile("archive.zip", "r") as z:
with z.open("data.npy", "r") as f:
f._update_crc = lambda newdata: None
data = f.read() # -> result only contains data from first frame
As independent cross-check, I tested decompressing the file with both 7z and WinRAR without issues. So I don't think the file is somehow invalid. This is the file: archive.zip
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-154537
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
再現コードは添付されたアーカイブに対して zipfile.ZipFile.open と z.open を使用します。まず、CPython の zipfile 実装で 2 フレームの zstd ケースを再現してください。data.npy を読み取ると両方のフレームが返され、通常の CRC チェックが成功し、この動作をカバーする回帰テストがあることを完了条件とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100