PEP 706: Address Greg's review (#3038)

Address Greg's review
This commit is contained in:
Petr Viktorin 2023-03-06 16:31:52 +01:00 committed by GitHub
parent dc4346298a
commit 47bf3eb00a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -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 users 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.