-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
gh-80145: Exclude '.' directory when adding directories to a tar archive #13738
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
Conversation
to a tar archive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the change to shutil warrants a mention in "What's New". The similar fix for zip archives did not add such a mention. The "What's New" line about the change to tarfile is fine IMO, though.
Also, since this changes the tarfile module (rather than shutil), this also should be tested in the tar module's tests.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
This should also be reviewed by @gustaebel, the expert on the tarfile module.
I changed the title to reflect what the patch does, as opposed the the symptom it prevents. This raises the question of whether it is always wrong for tarfile to add './', so that this is truly a bug fix, or only wrong when tarfile is called from shutil? In other words, is the bug possibly in the arguments passed by shutil, or tarfile not interpreting them fully? Tal Einat's approval of this PR was conditioned on an answer from a 'tarfile expert'. Lars is no longer reviewing. @serhiy-storchaka Can you decide this? Otherwise, since the tests still pass after merging main, I think this good to go. The OP changed test_tarfile as Tal requested. I removed the 3.11 backport label and updated a comment from 'bpo' to 'gh'. |
Well, it would leave out the permissions ("mode") and other metadata for the current directory, which might be used when extracting (possibly using a different tar implementation) into a specific directory that doesn't exist yet but which that utility might create, setting the mode from the tarchive? So it seems to me this might not be 100% backwards compatible. |
Isn't that the same as for zip archives? #72674 |
I am not sure that we should change I created an alternate PR #118152 which only changes |
Agreed, |
It is special because we have no way to create a tar file without the |
Surely we can do the equivalent of |
|
As a result of the current tarfile behavior, shutil.make_archive (xxx, tar, root_dir) results in a './' entry in the archive, which is wrong.