Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 706 implementation #23

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
16 changes: 15 additions & 1 deletion Doc/library/shutil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
Remove the archive format *name* from the list of supported formats.


.. function:: unpack_archive(filename[, extract_dir[, format]])
.. function:: unpack_archive(filename[, extract_dir[, format[, filter]]])

Unpack an archive. *filename* is the full path of the archive.

Expand All @@ -650,6 +650,14 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
registered for that extension. In case none is found,
a :exc:`ValueError` is raised.

*filter* is passed to the underlying unpacking function.
For zip files, *filter* is not accepted.
For tar files, it is recommended to set it to ``'data'``,
unless using features specific to tar and UNIX filesystems.
(See :ref:`tarfile-extraction-filter` for details.)
The ``'data'`` filter ·will become the default for tar files
encukou marked this conversation as resolved.
Show resolved Hide resolved
in Python 3.14.

.. audit-event:: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive

.. warning::
Expand All @@ -662,6 +670,9 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
.. versionchanged:: 3.7
Accepts a :term:`path-like object` for *filename* and *extract_dir*.

.. versionchanged:: 3.12
Added the *filter* argument.

.. function:: register_unpack_format(name, extensions, function[, extra_args[, description]])

Registers an unpack format. *name* is the name of the format and
Expand All @@ -672,6 +683,9 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
callable will receive the path of the archive, followed by the directory
the archive must be extracted to.

If *filter* is used with ``unpack_archive``, it will be passed to *function*
as an additional named argument.

When provided, *extra_args* is a sequence of ``(name, value)`` tuples that
will be passed as keywords arguments to the callable.

Expand Down
Loading