@@ -620,7 +620,7 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
620620 Remove the archive format *name * from the list of supported formats.
621621
622622
623- .. function :: unpack_archive(filename[, extract_dir[, format]])
623+ .. function :: unpack_archive(filename[, extract_dir[, format[, filter] ]])
624624
625625 Unpack an archive. *filename * is the full path of the archive.
626626
@@ -634,6 +634,15 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
634634 registered for that extension. In case none is found,
635635 a :exc: `ValueError ` is raised.
636636
637+ The keyword-only *filter * argument, which was added in Python 3.10.12,
638+ is passed to the underlying unpacking function.
639+ For zip files, *filter * is not accepted.
640+ For tar files, it is recommended to set it to ``'data' ``,
641+ unless using features specific to tar and UNIX-like filesystems.
642+ (See :ref: `tarfile-extraction-filter ` for details.)
643+ The ``'data' `` filter will become the default for tar files
644+ in Python 3.14.
645+
637646 .. audit-event :: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive
638647
639648 .. warning ::
@@ -646,18 +655,24 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
646655 .. versionchanged :: 3.7
647656 Accepts a :term: `path-like object ` for *filename * and *extract_dir *.
648657
658+ .. versionchanged :: 3.10.12
659+ Added the *filter * argument.
660+
649661.. function :: register_unpack_format(name, extensions, function[, extra_args[, description]])
650662
651663 Registers an unpack format. *name * is the name of the format and
652664 *extensions * is a list of extensions corresponding to the format, like
653665 ``.zip `` for Zip files.
654666
655667 *function * is the callable that will be used to unpack archives. The
656- callable will receive the path of the archive, followed by the directory
657- the archive must be extracted to.
658-
659- When provided, *extra_args * is a sequence of ``(name, value) `` tuples that
660- will be passed as keywords arguments to the callable.
668+ callable will receive:
669+
670+ - the path of the archive, as a positional argument;
671+ - the directory the archive must be extracted to, as a positional argument;
672+ - possibly a *filter * keyword argument, if it was given to
673+ :func: `unpack_archive `;
674+ - additional keyword arguments, specified by *extra_args * as a sequence
675+ of ``(name, value) `` tuples.
661676
662677 *description * can be provided to describe the format, and will be returned
663678 by the :func: `get_unpack_formats ` function.
0 commit comments