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

Bug report: shutil.make_archive() makes empty archive file even when root_dir does not exists #99203

Closed
Labels
3.11only security fixes3.12only security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@mski-iksm

Description

@mski-iksm

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’.

import shutilshutil.make_archive(base_name='aaa_archive', root_dir="not_existing_dir", format="zip")# This will raise FileNotFoundError in python ~3.9, where it doesn’t in 3.10~

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, whereos.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp