Skip to content

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

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

Merged
merged 4 commits into from
Apr 27, 2025

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented 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.


📚 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
Copy link
Contributor Author

mgorny commented Apr 26, 2025

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
Copy link
Contributor Author

mgorny commented Apr 26, 2025

The macOS failures don't seem related.

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
@mgorny
Copy link
Contributor Author

mgorny commented Apr 26, 2025

Thank you for your suggestions!

Copy link
Member

@gpshead gpshead left a comment

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
39 checks passed
@mgorny mgorny deleted the tarfile-stream-xz-preset-133005 branch April 28, 2025 02:08
@mgorny
Copy link
Contributor Author

mgorny commented Apr 28, 2025

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