Repository navigation
gh-161088: Make the gzip CLI replace its output file like gzip(1) - #161089
Merged
Merged
Conversation
Remove an existing file at the output name and create the output with O_EXCL and the input file's permission bits, so a symbolic link there is no longer followed.
Documentation build overview
|
# Conflicts: # Lib/gzip.py
gpshead
marked this pull request as ready for review
November 1, 2026 18:31
gpshead
enabled auto-merge (squash)
November 1, 2026 18:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Like
gzip -f, the CLI now unlinks an existing file at the output name and creates the output withO_EXCLand the input file'sst_mode & 0o777(subject to the umask), for both compression and decompression of file arguments; stdin/stdout use is unchanged. This keeps the existing "overwrite the old output" behaviour while no longer writing through a symlink, hardlink or fifo at that name. As a consequence a read-only input now gives a read-only output, and a directory the user cannot write to now fails instead of writing into an existing file there, so this is for main only. Only run on Linux: on Windows, removing a read-only existing output file would fail withPermissionError, which is untested.Fixes #161088
ANT-2026-00DXM84J ANT-2026-746G5PBP
python -m gzipwrites through a symlink at the output name and ignores the input mode #161088