python / python/cpython

`tarfile.open()` does not forward keyword arguments to the underlying `_Stream` object for zstd in stream mode

未關閉
#139,821 3 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib type-feature
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:

I found the bug when I was browsing the source code, so I just put the source code here:

    @classmethod
    def open(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs):
        # irrevalent code...
        elif "|" in mode:
            # irrevalent code...
            compresslevel = kwargs.pop("compresslevel", 6)
            preset = kwargs.pop("preset", None)
            stream = _Stream(name, filemode, comptype, fileobj, bufsize,
                             compresslevel, preset)
            # irrevalent code...

But the doc says that:

For modes 'w:zst', 'x:zst' and 'w|zst', tarfile.open() accepts the keyword argument level to specify the compression level of the file. The keyword argument options may also be passed, providing advanced Zstandard compression parameters described by CompressionParameter. The keyword argument zstd_dict can be passed to provide a ZstdDict, a Zstandard dictionary used to improve compression of smaller amounts of data.

So there're three keyword arguments: level, options and zstd_dict that need to pass to _Stream constructor, and the constructor needs to change to accept these keyword arguments.

I'll open a PR to fix this soon.

CPython versions tested on:

3.14

Operating systems tested on:

No response

Linked PRs
  • gh-139822

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 tarfile.open() 和 _Stream 建構函式開始,重點關注使用 zstd 的串流模式。驗證應如何轉送 level、options 和 zstd_dict,並確認對應的文件行為對 w|zst 有效;連結的 PR 表示這項工作已在進行中。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。