-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
tarfile: Support preset
argument to tarfile.open(mode="w|xz")
#133005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
mgorny
added a commit
to mgorny/cpython
that referenced
this issue
Apr 26, 2025
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.
mgorny
added a commit
to mgorny/cpython
that referenced
this issue
Apr 26, 2025
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.
mgorny
added a commit
to mgorny/cpython
that referenced
this issue
Apr 26, 2025
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.
gpshead
pushed a commit
that referenced
this issue
Apr 27, 2025
* 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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Feature or enhancement
Proposal:
Currently,
tarfile.open()
doesn't support specifying a compression level / preset when usingmode="w|xz"
. Technically this is documented (via not listingw|xz
among the modes supporting eithercompresslevel
orpreset
argument), it's kinda surprising (to the point of me thinking thatw|xz
takescompresslevel
instead ofpreset
, since the latter threw aTypeError
— and then being surprised that the default compression level was used), and quite limiting that you can't set the preset while using stream mode. On top of that, there does not seem to be any technical limitation preventing us from doing that.I'm working on a pull request to add that option.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
tarfile.open(mode="w|xz", preset=...)
#133007The text was updated successfully, but these errors were encountered: