python / python/cpython

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

Aperta
#139,821 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stdlib type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Parti da tarfile.open() e dal costruttore _Stream, concentrandoti sulle modalità di stream che utilizzano zstd. Verifica come debbano essere inoltrati level, options e zstd_dict e conferma che il comportamento corrispondente della documentazione funzioni per w|zst; la PR collegata indica che questo lavoro è già in corso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.