Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-99203:shutil.make_archive(): restore select CPython <= 3.10.5 behavior#99802
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
6t8k commentedNov 26, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Will look into the failed Windows tests later. |
…ehaviorRestore following CPython <= 3.10.5 behavior of `shutil.make_archive()`that went away as part ofgh-93160:Do not create an empty archive if `root_dir` is not a directory, and, inthat case, raise `FileNotFoundError` or `NotADirectoryError` regardlessof `format` choice. Beyond the brought-back behavior, the function maynow also raise these exceptions in `dry_run` mode.
6t8k commentedNov 27, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@giampaolo if I'm not mistaken, the P.S.: I acknowledge[1],[2] and won't force-push here any longer, sorry. |
serhiy-storchaka left a comment
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.
Creating an empty archive without raising an exception is definitely a bug. Leaving an empty archive and raising an exception is more in a grey area, but in any case it is better to not create it if we can to detect an error earlier.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
6t8k commentedJan 30, 2023
Thanks for the review! I addressed the findings. |
serhiy-storchaka left a comment
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.
LGTM.
Thank you for your response and sorry for the delay. This issue fell off my radar.
miss-islington commentedAug 16, 2023
Thanks@6t8k for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
miss-islington commentedAug 16, 2023
Sorry,@6t8k and@serhiy-storchaka, I could not cleanly backport this to |
….5 behavior (pythonGH-99802)Restore following CPython <= 3.10.5 behavior of shutil.make_archive()that went away as part ofpythongh-93160:Do not create an empty archive if root_dir is not a directory, and, inthat case, raise FileNotFoundError or NotADirectoryError regardlessof format choice. Beyond the brought-back behavior, the function maynow also raise these exceptions in dry_run mode.(cherry picked from commita86df29)Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
bedevere-bot commentedAug 16, 2023
GH-107998 is a backport of this pull request to the3.12 branch. |
…<= 3.10.5 behavior (pythonGH-99802)Restore following CPython <= 3.10.5 behavior of shutil.make_archive()that went away as part ofpythongh-93160:Do not create an empty archive if root_dir is not a directory, and, inthat case, raise FileNotFoundError or NotADirectoryError regardlessof format choice. Beyond the brought-back behavior, the function maynow also raise these exceptions in dry_run mode..(cherry picked from commita86df29)Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
bedevere-bot commentedAug 16, 2023
GH-107999 is a backport of this pull request to the3.11 branch. |
…0.5 behavior (GH-99802) (GH-107999)Restore following CPython <= 3.10.5 behavior of shutil.make_archive()that went away as part ofgh-93160:Do not create an empty archive if root_dir is not a directory, and, inthat case, raise FileNotFoundError or NotADirectoryError regardlessof format choice. Beyond the brought-back behavior, the function maynow also raise these exceptions in dry_run mode.(cherry picked from commita86df29)Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
…0.5 behavior (GH-99802) (#107998)gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 behavior (GH-99802)Restore following CPython <= 3.10.5 behavior of shutil.make_archive()that went away as part ofgh-93160:Do not create an empty archive if root_dir is not a directory, and, inthat case, raise FileNotFoundError or NotADirectoryError regardlessof format choice. Beyond the brought-back behavior, the function maynow also raise these exceptions in dry_run mode.(cherry picked from commita86df29)Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
root_dirdoes not exist, or is not a directory, then CPython >3.10.5 will create an empty archive, so introduce an explicit check for it being a directory.shutil.make_archive()may then raiseFileNotFoundErrororNotADirectoryErrorbefore proceeding to call the internal format-specific archive creation function, as was formerly (implicitly) caused byos.chdir(root_dir), restoring CPython <=3.10.5 behavior._make_tarball()and_make_zipfile()scenario: although the former, unlike the latter, may already causeNotADirectoryErrororFileNotFoundErrorto be raised with respect toroot_dirwithout this proposed change, an empty archive will still be created. On the other hand,_make_zipfile(), is able to create an empty archive while not raising any exceptions, so test it as well, even thoughmake_archive()would otherwise already be covered bytest_make_tarfile_rootdir_nodir(), which runs regardless of zlib availability.