Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,10 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
uses the current owner and group.
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what the rules are re-auditing, would it be better to do:

base_name = base_name ?? os.fsdecode(base_name)
root_dir = root_dir ?? os.fsdecode(root_dir)
base_dir = base_dir ?? os.fsdecode(base_dir)

before the audit call or after?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by ?? ?

Copy link
Contributor Author

@graingert graingert Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://peps.python.org/pep-0505/ syntax, but it's not used should be something like

base_name = base_name if base_name is None else os.fsdecode(base_name) 
root_dir = root_dir if root_dir is None else os.fsdecode(root_dir)
base_dir = base_dir if base_dir is None else os.fsdecode(base_dir)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaning is not None I assume!

sys.audit("shutil.make_archive", base_name, format, root_dir, base_dir)
base_name = os.fsdecode(base_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn’t fsdecode about bytes-str decoding, and fspath for pathlike-to-OS-native conversion?

save_cwd = os.getcwd()
if root_dir is not None:
root_dir = os.fsdecode(root_dir)
if logger is not None:
logger.debug("changing into '%s'", root_dir)
base_name = os.path.abspath(base_name)
Expand All @@ -1040,6 +1042,7 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,

if base_dir is None:
base_dir = os.curdir
base_dir = os.fsdecode(base_dir)

kwargs = {'dry_run': dry_run, 'logger': logger}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
always support pathlib in shutil.make_archive