@@ -619,22 +619,23 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
619619
620620 Create an archive file (such as zip or tar) and return its name.
621621
622- *base_name * is the name of the file to create, including the path, minus
623- any format-specific extension.
622+ *base_name * is the :term: ` path-like object ` specifying the name of the file
623+ to create, including the path, minus any format-specific extension.
624624
625625 *format * is the archive format: one of
626626 "zip" (if the :mod: `zlib ` module is available), "tar", "gztar" (if the
627627 :mod: `zlib ` module is available), "bztar" (if the :mod: `bz2 ` module is
628628 available), "xztar" (if the :mod: `lzma ` module is available), or "zstdtar"
629629 (if the :mod: `compression.zstd ` module is available).
630630
631- *root_dir * is a directory that will be the root directory of the
632- archive, all paths in the archive will be relative to it; for example,
633- we typically chdir into *root_dir * before creating the archive.
631+ *root_dir * is the :term: `path-like object ` specifying a directory that will
632+ be the root directory of the archive, all paths in the archive will be
633+ relative to it; for example, we typically chdir into *root_dir * before
634+ creating the archive.
634635
635- *base_dir * is the directory where we start archiving from;
636- i.e. *base_dir * will be the common prefix of all files and
637- directories in the archive. *base_dir * must be given relative
636+ *base_dir * is the :term: ` path-like object ` specifying a directory where we
637+ start archiving from; i.e. *base_dir * will be the common prefix of all files
638+ and directories in the archive. *base_dir * must be given relative
638639 to *root_dir *. See :ref: `shutil-archiving-example-with-basedir ` for how to
639640 use *base_dir * and *root_dir * together.
640641
@@ -669,6 +670,9 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
669670 This function is now made thread-safe during creation of standard
670671 ``.zip `` and tar archives.
671672
673+ .. versionchanged :: 3.15
674+ Accepts a :term: `path-like object ` for *base_name *.
675+
672676.. function :: get_archive_formats()
673677
674678 Return a list of supported formats for archiving.
@@ -814,10 +818,10 @@ Archiving example
814818In this example, we create a gzip'ed tar-file archive containing all files
815819found in the :file: `.ssh ` directory of the user::
816820
821+ >>> from pathlib import Path
817822 >>> from shutil import make_archive
818- >>> import os
819- >>> archive_name = os.path.expanduser(os.path.join('~', 'myarchive'))
820- >>> root_dir = os.path.expanduser(os.path.join('~', '.ssh'))
823+ >>> archive_name = Path.home() / 'myarchive'
824+ >>> root_dir = Path.home() / '.ssh'
821825 >>> make_archive(archive_name, 'gztar', root_dir)
822826 '/Users/tarek/myarchive.tar.gz'
823827
@@ -858,9 +862,9 @@ we show how to use :func:`make_archive`, but this time with the usage of
858862 In the final archive, :file: `please_add.txt ` should be included, but
859863:file: `do_not_add.txt ` should not. Therefore we use the following::
860864
865+ >>> from pathlib import Path
861866 >>> from shutil import make_archive
862- >>> import os
863- >>> archive_name = os.path.expanduser(os.path.join('~', 'myarchive'))
867+ >>> archive_name = Path.home() / 'myarchive'
864868 >>> make_archive(
865869 ... archive_name,
866870 ... 'tar',
0 commit comments