`tarfile.open()` does not forward keyword arguments to the underlying `_Stream` object for zstd in stream mode
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 tarfile.open() 和 _Stream 构造函数开始,重点关注使用 zstd 的流模式。验证应如何转发 level、options 和 zstd_dict,并确认相应的文档行为对 w|zst 有效;链接的 PR 表明这项工作已经在进行中。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100