mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-99203: shutil.make_archive(): restore select CPython <= 3.10.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 a86df298df
)
Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
This commit is contained in:
parent
4421c65f08
commit
5d9f20a06c
3 changed files with 52 additions and 0 deletions
|
@ -1156,6 +1156,10 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
|
|||
supports_root_dir = getattr(func, 'supports_root_dir', False)
|
||||
save_cwd = None
|
||||
if root_dir is not None:
|
||||
stmd = os.stat(root_dir).st_mode
|
||||
if not stat.S_ISDIR(stmd):
|
||||
raise NotADirectoryError(errno.ENOTDIR, 'Not a directory', root_dir)
|
||||
|
||||
if supports_root_dir:
|
||||
# Support path-like base_name here for backwards-compatibility.
|
||||
base_name = os.fspath(base_name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue