parent
dc4346298a
commit
47bf3eb00a
|
@ -210,7 +210,7 @@ Filters
|
|||
:external+py3.11:meth:`TarFile.extract <tarfile.TarFile.extract>` and
|
||||
:external+py3.11:meth:`TarFile.extractall <tarfile.TarFile.extractall>` methods
|
||||
will grow a ``filter`` keyword-only parameter,
|
||||
which takes a function with the signature::
|
||||
which takes a callable that can be called as::
|
||||
|
||||
filter(/, member: TarInfo, path: str) -> TarInfo|None
|
||||
|
||||
|
@ -225,6 +225,11 @@ The function can also raise an exception.
|
|||
This can, depending on ``TarFile.errorlevel``,
|
||||
abort the extraction or cause the member to be skipped.
|
||||
|
||||
.. note::
|
||||
|
||||
If extraction is aborted, the archive may be left partially
|
||||
extracted. It is the user’s responsibility to clean up.
|
||||
|
||||
We will also provide a set of defaults for common use cases.
|
||||
In addition to a function, the ``filter`` argument can be one
|
||||
of the following strings:
|
||||
|
@ -272,6 +277,8 @@ of the following strings:
|
|||
* Ignore user and group info (set ``uid``, ``gid``, ``uname``, ``gname``
|
||||
to ``None``).
|
||||
|
||||
Any other string will cause a ``ValueError``.
|
||||
|
||||
The corresponding filter functions will be available as
|
||||
``tarfile.fully_trusted_filter()``, ``tarfile.tar_filter()``, etc., so
|
||||
they can be easily used in custom policies.
|
||||
|
|
Loading…
Reference in New Issue