gh-74696: Pass root_dir to custom archivers which support it (GH-94251)

Co-authored-by: Éric <merwok@netwok.org>
This commit is contained in:
Serhiy Storchaka 2022-10-05 12:48:59 +03:00 committed by GitHub
parent 4b83cd0b22
commit e3ef400be7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 17 deletions

View file

@ -575,9 +575,10 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
.. note::
This function is not thread-safe when custom archivers registered
with :func:`register_archive_format` are used. In this case it
with :func:`register_archive_format` do not support the *root_dir*
argument. In this case it
temporarily changes the current working directory of the process
to perform archiving.
to *root_dir* to perform archiving.
.. versionchanged:: 3.8
The modern pax (POSIX.1-2001) format is now used instead of
@ -614,12 +615,21 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
Further arguments are passed as keyword arguments: *owner*, *group*,
*dry_run* and *logger* (as passed in :func:`make_archive`).
If *function* has the custom attribute ``function.supports_root_dir`` set to ``True``,
the *root_dir* argument is passed as a keyword argument.
Otherwise the current working directory of the process is temporarily
changed to *root_dir* before calling *function*.
In this case :func:`make_archive` is not thread-safe.
If given, *extra_args* is a sequence of ``(name, value)`` pairs that will be
used as extra keywords arguments when the archiver callable is used.
*description* is used by :func:`get_archive_formats` which returns the
list of archivers. Defaults to an empty string.
.. versionchanged:: 3.12
Added support for functions supporting the *root_dir* argument.
.. function:: unregister_archive_format(name)