Skip to content

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

Merged
gpshead merged 4 commits into
python:mainfrom
mgorny:tarfile-stream-xz-preset-133005
Apr 27, 2025
Merged

gh-133005: Support tarfile.open(mode="w|xz", preset=...)#133007
gpshead merged 4 commits into
python:mainfrom
mgorny:tarfile-stream-xz-preset-133005

Conversation

@mgorny

@mgorny mgorny commented Apr 26, 2025

Copy link
Copy Markdown
Contributor

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.


📚 Documentation preview 📚: https://cpython-previews--133007.org.readthedocs.build/

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 mgorny force-pushed the tarfile-stream-xz-preset-133005 branch from 697bbca to ebf37b6 Compare April 26, 2025 12:49
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.
@mgorny

mgorny commented Apr 26, 2025

Copy link
Copy Markdown
Contributor Author

I've added raising an exception if compresslevel or preset are specified for wrong compression as a second commit, since it's non-critical to the issue at hand, so it can be easily removed if you don't like it.

@mgorny

mgorny commented Apr 26, 2025

Copy link
Copy Markdown
Contributor Author

The macOS failures don't seem related.

Comment thread Doc/library/tarfile.rst Outdated
Comment thread Misc/NEWS.d/next/Library/2025-04-26-14-44-21.gh-issue-133005.y4SRfk.rst Outdated
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
@mgorny

mgorny commented Apr 26, 2025

Copy link
Copy Markdown
Contributor Author

Thank you for your suggestions!

@gpshead gpshead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the silently ignored when irrelevant compresslevel= that now raises causes an issue during the beta period we can revisit that error addition. (the error codepath will be adjusted with zstd support landing soon as well)

@gpshead gpshead enabled auto-merge (squash) April 27, 2025 21:12
@gpshead gpshead merged commit 019ee49 into python:main Apr 27, 2025
@mgorny mgorny deleted the tarfile-stream-xz-preset-133005 branch April 28, 2025 02:08
@mgorny

mgorny commented Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

Thank you! It was also my logic that it's better to add the error while we're still in alpha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants