`tarfile.open()` does not forward keyword arguments to the underlying `_Stream` object for zstd in stream mode
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at tarfile.open() and the _Stream constructor, focusing on stream modes using zstd. Verify how level, options, and zstd_dict should be forwarded and confirm that the corresponding documentation behavior works for w|zst; the linked PR indicates this work is already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100