-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-139679: Resolve symbolic links to directories when shutil.make_archive() is used to create a zip file #139856
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
Open
cowgoesmoo69
wants to merge
17
commits into
python:main
Choose a base branch
from
cowgoesmoo69:shutil-default-zipfile-behaviour
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
gh-139679: Resolve symbolic links to directories when shutil.make_archive() is used to create a zip file #139856
cowgoesmoo69
wants to merge
17
commits into
python:main
from
cowgoesmoo69:shutil-default-zipfile-behaviour
+100
−8
Conversation
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
This causes symbolic links to both files and directories to be resolved and the link targets included in the resulting zipfile. This matches the default behaviour of command-line zip on Linux/UNIX systems (i.e. systems where filesystems supporting symbolic linking are likely to be present).
Docstring now describes the behaviour when symbolic links to files and directories are encountered.
Docstring now describes behaviour when hard links to files are encountered.
Improved readability and added comments to _create_files_symlinks() for making a test directory structure. Expanded docstring for test_make_zipfile_symlink_behaviour to explain purpose of test and reasons why the test might be skipped in a Windows environment. Updated test with try-finally for proper clean up of files after the test.
First line of docstring within a test gets printed out when test runs. No other tests appear to be doing that so switched to commented lines instead.
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
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.
This aligns the default behaviour of shutil.make_archive() for creating zip files, with the default behaviour of command-line zip utilities on Linux/UNIX/Windows. Now, if a symbolic link to a directory is encountered when creating the list of files for the zip file, it is followed and the contents of the target directory included.
Docstring of shutil._make_zipfile() has been expanded to document the new behaviour and warn about the risk of infinite recursion that exists with os.walk().
test_shutil.py has been updated with tests to prove the new behaviour is working as expected. Explanation of how to avoid the test being skipped on Windows is included.
follow_links
parameter toshutil.make_archive()
#139679