-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Bug report: shutil.make_archive() makes empty archive file even when root_dir does not exists #99203
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
6t8k
added a commit
to 6t8k/cpython
that referenced
this issue
Nov 27, 2022
…10.5 behavior Restore following CPython <= 3.10.5 behavior of `shutil.make_archive()` that went away as part of pythongh-93160: Do not create an empty archive if `root_dir` is not a directory, and, in that case, raise `FileNotFoundError` or `NotADirectoryError` regardless of `format` choice. Beyond the brought-back behavior, the function may now also raise these exceptions in `dry_run` mode.
Gentle ping: |
6t8k
added a commit
to 6t8k/cpython
that referenced
this issue
Jan 30, 2023
serhiy-storchaka
pushed a commit
that referenced
this issue
Aug 16, 2023
…avior (GH-99802) Restore following CPython <= 3.10.5 behavior of shutil.make_archive() that went away as part of gh-93160: Do not create an empty archive if root_dir is not a directory, and, in that case, raise FileNotFoundError or NotADirectoryError regardless of format choice. Beyond the brought-back behavior, the function may now also raise these exceptions in dry_run mode.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Aug 16, 2023
….5 behavior (pythonGH-99802) Restore following CPython <= 3.10.5 behavior of shutil.make_archive() that went away as part of pythongh-93160: Do not create an empty archive if root_dir is not a directory, and, in that case, raise FileNotFoundError or NotADirectoryError regardless of format choice. Beyond the brought-back behavior, the function may now also raise these exceptions in dry_run mode. (cherry picked from commit a86df29) Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
serhiy-storchaka
pushed a commit
to serhiy-storchaka/cpython
that referenced
this issue
Aug 16, 2023
…<= 3.10.5 behavior (pythonGH-99802) Restore following CPython <= 3.10.5 behavior of shutil.make_archive() that went away as part of pythongh-93160: Do not create an empty archive if root_dir is not a directory, and, in that case, raise FileNotFoundError or NotADirectoryError regardless of format choice. Beyond the brought-back behavior, the function may now also raise these exceptions in dry_run mode.. (cherry picked from commit a86df29) Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
serhiy-storchaka
added a commit
that referenced
this issue
Aug 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 of gh-93160: Do not create an empty archive if root_dir is not a directory, and, in that case, raise FileNotFoundError or NotADirectoryError regardless of format choice. Beyond the brought-back behavior, the function may now also raise these exceptions in dry_run mode. (cherry picked from commit a86df29) Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
Yhg1s
pushed a commit
that referenced
this issue
Aug 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 of gh-93160: Do not create an empty archive if root_dir is not a directory, and, in that case, raise FileNotFoundError or NotADirectoryError regardless of format choice. Beyond the brought-back behavior, the function may now also raise these exceptions in dry_run mode. (cherry picked from commit a86df29) Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
Would it be an idea to backport this fix to 3.10 as well? Because there is now a slight range of Python versions where using |
Only security fixes are accepted for 3.10 |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Bug report
In python 3.10+, shutil.make_archive() makes empty archive file and does not raise any error even when root_dir does not exists.
In python -3.9, FileNotFoundError is raised with message
[Errno 2] No such file or directory: ‘xxxxxxx’
.I though making empty archive file is unnatural, so fixing it maybe good for backward compatibility.
I think this problem is caused in this line, where
os.chdir(root_dir)
is not called anymore.In the previous code,
os.chdir(root_dir)
will raise FileNotFoundError when root_dir does not exists.https://github.com/python/cpython/pull/93160/files#diff-db8ac59326160713929e0e1973aef54f0280fe9f154ef24d14244909a0e0689bL1084
I thought checking the existence of root_dir and raise FileNotFoundError when root_dir is not found, might be a good implementation to fix this problem.
Linked PRs
shutil.make_archive()
: restore select CPython <= 3.10.5 behavior #99802The text was updated successfully, but these errors were encountered: