Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
serhiy-storchaka merged 6 commits intopython:mainfrom6t8k:gh-99203
Aug 16, 2023

Conversation

@6t8k
Copy link
Contributor

@6t8k6t8k commentedNov 26, 2022
edited
Loading

  • Without this proposed change, if the path held byroot_dir does 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 raiseFileNotFoundError orNotADirectoryError before 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.
  • For consistency, decided to raise the exception in dry run mode too
  • Add corresponding regression tests for both the_make_tarball() and_make_zipfile() scenario: although the former, unlike the latter, may already causeNotADirectoryError orFileNotFoundError to be raised with respect toroot_dir without 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.

@6t8k
Copy link
ContributorAuthor

6t8k commentedNov 26, 2022
edited
Loading

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
Copy link
ContributorAuthor

6t8k commentedNov 27, 2022
edited
Loading

@giampaolo if I'm not mistaken, theCODEOWNERS lines forftplib andshutil seem to be missing a* suffix and do not seem to match the respective files as a result.

P.S.: I acknowledge[1],[2] and won't force-push here any longer, sorry.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a 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.

@6t8k
Copy link
ContributorAuthor

Thanks for the review! I addressed the findings.

@6t8k6t8k requested review fromserhiy-storchaka and removed request forgiampaoloJanuary 30, 2023 20:34
Copy link
Member

@serhiy-storchakaserhiy-storchaka left a 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.

6t8k reacted with heart emoji
@serhiy-storchakaserhiy-storchaka added type-bugAn unexpected behavior, bug, or error needs backport to 3.11only security fixes needs backport to 3.12only security fixes labelsAug 16, 2023
@serhiy-storchakaserhiy-storchaka merged commita86df29 intopython:mainAug 16, 2023
@miss-islington
Copy link
Contributor

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

Sorry,@6t8k and@serhiy-storchaka, I could not cleanly backport this to3.11 due to a conflict.
Please backport usingcherry_picker on command line.
cherry_picker a86df298df5b02e2d69ea6879e9ed10a7adb85d0 3.11

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestAug 16, 2023
….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
Copy link

GH-107998 is a backport of this pull request to the3.12 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.12only security fixes labelAug 16, 2023
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull requestAug 16, 2023
…<= 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
Copy link

GH-107999 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelAug 16, 2023
@serhiy-storchakaserhiy-storchaka removed their assignmentAug 16, 2023
serhiy-storchaka added a commit that referenced this pull requestAug 16, 2023
…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>
Yhg1s pushed a commit that referenced this pull requestAug 16, 2023
…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>
@6t8k6t8k deleted the gh-99203 branchAugust 16, 2023 19:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

Assignees

No one assigned

Labels

type-bugAn unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@6t8k@miss-islington@bedevere-bot@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp