compression.zstd produces a broken archive if nothing is written
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
Creating an empty zstd archive without any .write() calls produces a zero-byte file that fails to open later.
import compression.zstd as zstd
with zstd.open("test.zst", "w") as f:
pass
with zstd.open("test.zst", "r") as f:
f.read() # EOFError here. Won't happen if you just pass instead of reading
Traceback (most recent call last):
File "<python-input-4>", line 2, in <module>
f.read()
~~~~~~^^
File "compression\zstd\_zstdfile.py", line 173, in read
File "compression\_common\_streams.py", line 118, in readall
File "compression\_common\_streams.py", line 99, in read
EOFError: Compressed file ended before the end-of-stream marker was reached
Reference Zstandard v.1.5.7 also won't open the resulting empty file:
zstd.exe -d test.zst -o aa.txt
zstd: test.zst: unexpected end of file
stat test.zst
File: test.zst
Size: 0 Blocks: 0 IO Block: 65536 regular empty file
Under same circumstances compression.gzip produces a proper non-empty gzip file that can decompresses into an empty string, which would probably be a desirable behaviour. In the current compression.zstd, you can have that by calling write(b"") instead of pass.
Tested on Windows with recent 3.15rc and 3.14 builds as well as on Linux with 3.10 via backports.zstd.
Python 3.15.0rc1 (tags/v3.15.0rc1:37e98da, Aug 4 2026, 11:37:18) [MSC v.1951 64 bit (AMD64)] on win32
Python 3.14.7 (tags/v3.14.7:823f032, Aug 5 2026, 10:51:32) [MSC v.1944 64 bit (AMD64)] on win32
Python 3.10.12 (main, Jun 22 2026, 18:55:27) [GCC 11.4.0] on linux
Devguide suggested tagging @emmatyping for .zstd bugs.
CPython versions tested on:
3.15, 3.14, 3.10
Operating systems tested on:
Windows, Linux
Linked PRs
- gh-155342
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
compression/zstd/_zstdfile.py と、compression/_common_streams.py に示されている読み取りパスから始めます。空のコンテキストマネージャーの場合を再現し、次に空の write() の場合および gzip の挙動と比較します。write() の呼び出しなしで作成されたアーカイブを再度開いて空として読み取れるようになり、回帰テストのカバレッジが追加されれば完了です。リンク先の PR gh-155342 は、作業がすでに進行中であることを示しています。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100