@@ -537,7 +537,7 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
537
537
Remove the archive format *name * from the list of supported formats.
538
538
539
539
540
- .. function :: unpack_archive(filename[, extract_dir[, format]])
540
+ .. function :: unpack_archive(filename[, extract_dir[, format[, filter] ]])
541
541
542
542
Unpack an archive. *filename * is the full path of the archive.
543
543
@@ -551,6 +551,16 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
551
551
registered for that extension. In case none is found,
552
552
a :exc: `ValueError ` is raised.
553
553
554
+ The keyword-only *filter * argument is passed to the underlying unpacking
555
+ function. For zip files, *filter * is not accepted.
556
+ For tar files, it is recommended to set it to ``'data' ``,
557
+ unless using features specific to tar and UNIX-like filesystems.
558
+ (See :ref: `tarfile-extraction-filter ` for details.)
559
+ The ``'data' `` filter will become the default for tar files
560
+ in Python 3.14.
561
+
562
+ .. versionchanged :: 3.6.16
563
+ Added the *filter * argument.
554
564
555
565
.. function :: register_unpack_format(name, extensions, function[, extra_args[, description]])
556
566
@@ -559,11 +569,14 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
559
569
``.zip `` for Zip files.
560
570
561
571
*function * is the callable that will be used to unpack archives. The
562
- callable will receive the path of the archive, followed by the directory
563
- the archive must be extracted to.
564
-
565
- When provided, *extra_args * is a sequence of ``(name, value) `` tuples that
566
- will be passed as keywords arguments to the callable.
572
+ callable will receive:
573
+
574
+ - the path of the archive, as a positional argument;
575
+ - the directory the archive must be extracted to, as a positional argument;
576
+ - possibly a *filter * keyword argument, if it was given to
577
+ :func: `unpack_archive `;
578
+ - additional keyword arguments, specified by *extra_args * as a sequence
579
+ of ``(name, value) `` tuples.
567
580
568
581
*description * can be provided to describe the format, and will be returned
569
582
by the :func: `get_unpack_formats ` function.
0 commit comments