]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-133005: Support `tarfile.open(mode="w|xz", preset=...)` (GH-133007)
authorMichał Górny <mgorny@gentoo.org>
Sun, 27 Apr 2025 22:19:59 +0000 (00:19 +0200)
committerGitHub <noreply@github.com>
Sun, 27 Apr 2025 22:19:59 +0000 (22:19 +0000)
commit019ee49d50b6466f2f18035c812fa87d20c24a46
treea77d65e9adc178f4ceadbdf9eec4633e06e3536c
parent146b981f764cc8975910066096dc2f6cb33beec6
gh-133005: Support `tarfile.open(mode="w|xz", preset=...)` (GH-133007)

* gh-133005: Support `tarfile.open(mode="w|xz", preset=...)`

Support passing the `preset` option to `tarfile.open` when the file
is open with `mode="w|xz"`.  This aligns the behavior with `"w:xz"`
mode.

* Also raise an error for `compresslevel` or `preset` with wrong mode

Raise an error if `compresslevel` or `preset` argument is specified
for stream mode with incorrect compression. This should reduce the risk
of mistakes and align the stream modes with regular modes, that raise
an implicit TypeError on unsupported arguments.

* Apply suggestions from code review

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Doc/library/tarfile.rst
Lib/tarfile.py
Misc/NEWS.d/next/Library/2025-04-26-14-44-21.gh-issue-133005.y4SRfk.rst [new file with mode: 0644]