Skip to content

Commit 10a05d8

Browse files
encukoumcepl
authored andcommitted
Adjust the docs for 3.10.12
1 parent 52dd746 commit 10a05d8

File tree

3 files changed

+52
-32
lines changed

3 files changed

+52
-32
lines changed

Doc/library/shutil.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,9 @@ 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 is passed to the underlying unpacking
638-
function. For zip files, *filter* is not accepted.
637+
The keyword-only *filter* argument, which was added in Python 3.11.4,
638+
is passed to the underlying unpacking function.
639+
For zip files, *filter* is not accepted.
639640
For tar files, it is recommended to set it to ``'data'``,
640641
unless using features specific to tar and UNIX-like filesystems.
641642
(See :ref:`tarfile-extraction-filter` for details.)
@@ -654,7 +655,7 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
654655
.. versionchanged:: 3.7
655656
Accepts a :term:`path-like object` for *filename* and *extract_dir*.
656657

657-
.. versionchanged:: 3.12
658+
.. versionchanged:: 3.11.4
658659
Added the *filter* argument.
659660

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

Doc/library/tarfile.rst

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ Some facts and figures:
3636
.. versionchanged:: 3.3
3737
Added support for :mod:`lzma` compression.
3838

39-
.. versionchanged:: 3.12
40-
Archives are extracted using a :ref:`filter <tarfile-extraction-filter>`,
41-
which makes it possible to either limit surprising/dangerous features,
42-
or to acknowledge that they are expected and the archive is fully trusted.
43-
By default, archives are fully trusted, but this default is deprecated
44-
and slated to change in Python 3.14.
45-
4639

4740
.. function:: open(name=None, mode='r', fileobj=None, bufsize=10240, **kwargs)
4841

@@ -437,8 +430,8 @@ be finalized; only the internally used file object will be closed. See the
437430
are used to set the owner/group for the extracted files. Otherwise, the named
438431
values from the tarfile are used.
439432

440-
The *filter* argument specifies how ``members`` are modified or rejected
441-
before extraction.
433+
The *filter* argument, which was added in Python 3.11.4, specifies how
434+
``members`` are modified or rejected before extraction.
442435
See :ref:`tarfile-extraction-filter` for details.
443436
It is recommended to set this explicitly depending on which *tar* features
444437
you need to support.
@@ -459,7 +452,7 @@ be finalized; only the internally used file object will be closed. See the
459452
.. versionchanged:: 3.6
460453
The *path* parameter accepts a :term:`path-like object`.
461454

462-
.. versionchanged:: 3.12
455+
.. versionchanged:: 3.11.4
463456
Added the *filter* parameter.
464457

465458

@@ -495,7 +488,7 @@ be finalized; only the internally used file object will be closed. See the
495488
.. versionchanged:: 3.6
496489
The *path* parameter accepts a :term:`path-like object`.
497490

498-
.. versionchanged:: 3.12
491+
.. versionchanged:: 3.11.4
499492
Added the *filter* parameter.
500493

501494

@@ -533,7 +526,7 @@ be finalized; only the internally used file object will be closed. See the
533526

534527
.. attribute:: TarFile.extraction_filter
535528

536-
.. versionadded:: 3.12
529+
.. versionadded:: 3.11.4
537530

538531
The :ref:`extraction filter <tarfile-extraction-filter>` used
539532
as a default for the *filter* argument of :meth:`~TarFile.extract`
@@ -544,10 +537,12 @@ be finalized; only the internally used file object will be closed. See the
544537
argument to :meth:`~TarFile.extract`.
545538

546539
If ``extraction_filter`` is ``None`` (the default),
547-
calling an extraction method without a *filter* argument will raise a
548-
``DeprecationWarning``,
549-
and fall back to the :func:`fully_trusted <fully_trusted_filter>` filter,
550-
whose dangerous behavior matches previous versions of Python.
540+
calling an extraction method without a *filter* argument will
541+
use the :func:`fully_trusted <fully_trusted_filter>` filter for
542+
compatibility with previous Python versions.
543+
544+
In Python 3.12+, leaving ``extraction_filter=None`` will emit a
545+
``DeprecationWarning``.
551546

552547
In Python 3.14+, leaving ``extraction_filter=None`` will cause
553548
extraction methods to use the :func:`data <data_filter>` filter by default.
@@ -652,6 +647,11 @@ Different :class:`TarInfo` methods handle ``None`` differently:
652647
- :meth:`~TarFile.addfile` will fail.
653648
- :meth:`~TarFile.list` will print a placeholder string.
654649

650+
651+
.. versionchanged:: 3.11.4
652+
Added :meth:`~TarInfo.replace` and handling of ``None``.
653+
654+
655655
.. class:: TarInfo(name="")
656656

657657
Create a :class:`TarInfo` object.
@@ -700,7 +700,7 @@ A ``TarInfo`` object has the following public data attributes:
700700
Time of last modification in seconds since the :ref:`epoch <epoch>`,
701701
as in :attr:`os.stat_result.st_mtime`.
702702

703-
.. versionchanged:: 3.12
703+
.. versionchanged:: 3.11.4
704704

705705
Can be set to ``None`` for :meth:`~TarFile.extract` and
706706
:meth:`~TarFile.extractall`, causing extraction to skip applying this
@@ -711,7 +711,7 @@ A ``TarInfo`` object has the following public data attributes:
711711

712712
Permission bits, as for :func:`os.chmod`.
713713

714-
.. versionchanged:: 3.12
714+
.. versionchanged:: 3.11.4
715715

716716
Can be set to ``None`` for :meth:`~TarFile.extract` and
717717
:meth:`~TarFile.extractall`, causing extraction to skip applying this
@@ -738,7 +738,7 @@ A ``TarInfo`` object has the following public data attributes:
738738

739739
User ID of the user who originally stored this member.
740740

741-
.. versionchanged:: 3.12
741+
.. versionchanged:: 3.11.4
742742

743743
Can be set to ``None`` for :meth:`~TarFile.extract` and
744744
:meth:`~TarFile.extractall`, causing extraction to skip applying this
@@ -749,7 +749,7 @@ A ``TarInfo`` object has the following public data attributes:
749749

750750
Group ID of the user who originally stored this member.
751751

752-
.. versionchanged:: 3.12
752+
.. versionchanged:: 3.11.4
753753

754754
Can be set to ``None`` for :meth:`~TarFile.extract` and
755755
:meth:`~TarFile.extractall`, causing extraction to skip applying this
@@ -760,7 +760,7 @@ A ``TarInfo`` object has the following public data attributes:
760760

761761
User name.
762762

763-
.. versionchanged:: 3.12
763+
.. versionchanged:: 3.11.4
764764

765765
Can be set to ``None`` for :meth:`~TarFile.extract` and
766766
:meth:`~TarFile.extractall`, causing extraction to skip applying this
@@ -771,7 +771,7 @@ A ``TarInfo`` object has the following public data attributes:
771771

772772
Group name.
773773

774-
.. versionchanged:: 3.12
774+
.. versionchanged:: 3.11.4
775775

776776
Can be set to ``None`` for :meth:`~TarFile.extract` and
777777
:meth:`~TarFile.extractall`, causing extraction to skip applying this
@@ -786,7 +786,7 @@ A ``TarInfo`` object has the following public data attributes:
786786
uid=..., gid=..., uname=..., gname=...,
787787
deep=True)
788788

789-
.. versionadded:: 3.12
789+
.. versionadded:: 3.11.4
790790

791791
Return a *new* copy of the :class:`!TarInfo` object with the given attributes
792792
changed. For example, to return a ``TarInfo`` with the group name set to
@@ -851,7 +851,7 @@ A :class:`TarInfo` object also provides some convenient query methods:
851851
Extraction filters
852852
------------------
853853

854-
.. versionadded:: 3.12
854+
.. versionadded:: 3.11.4
855855

856856
The *tar* format is designed to capture all details of a UNIX-like filesystem,
857857
which makes it very powerful.
@@ -888,9 +888,10 @@ can be:
888888

889889
* ``None`` (default): Use :attr:`TarFile.extraction_filter`.
890890

891-
If that is also ``None`` (the default), raise a ``DeprecationWarning``,
892-
and fall back to the ``'fully_trusted'`` filter, whose dangerous behavior
893-
matches previous versions of Python.
891+
If that is also ``None`` (the default), the ``'fully_trusted'``
892+
filter will be used (for compatibility with earlier versions of Python).
893+
894+
In Python 3.12, the default will emit a ``DeprecationWarning``.
894895

895896
In Python 3.14, the ``'data'`` filter will become the default instead.
896897
It's possible to switch earlier; see :attr:`TarFile.extraction_filter`.
@@ -1027,7 +1028,7 @@ Also note that:
10271028
Supporting older Python versions
10281029
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10291030

1030-
Extraction filters were added to Python 3.12, but may be backported to older
1031+
Extraction filters were added to Python 3.12, and are backported to older
10311032
versions as security updates.
10321033
To check whether the feature is available, use e.g.
10331034
``hasattr(tarfile, 'data_filter')`` rather than checking the Python version.
@@ -1174,6 +1175,8 @@ Command-line options
11741175
Only string names are accepted (that is, ``fully_trusted``, ``tar``,
11751176
and ``data``).
11761177

1178+
.. versionadded:: 3.11.4
1179+
11771180
.. _tar-examples:
11781181

11791182
Examples
@@ -1183,7 +1186,7 @@ How to extract an entire tar archive to the current working directory::
11831186

11841187
import tarfile
11851188
tar = tarfile.open("sample.tar.gz")
1186-
tar.extractall(filter='data')
1189+
tar.extractall()
11871190
tar.close()
11881191

11891192
How to extract a subset of a tar archive with :meth:`TarFile.extractall` using

Doc/whatsnew/3.10.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,3 +2332,19 @@ The deprecated :mod:`mailcap` module now refuses to inject unsafe text
23322332
text, it will warn and act as if a match was not found (or for test commands,
23332333
as if the test failed).
23342334
(Contributed by Petr Viktorin in :gh:`98966`.)
2335+
2336+
Notable Changes in 3.10.12
2337+
==========================
2338+
2339+
tarfile
2340+
-------
2341+
2342+
* The extraction methods in :mod:`tarfile`, and :func:`shutil.unpack_archive`,
2343+
have a new a *filter* argument that allows limiting tar features than may be
2344+
surprising or dangerous, such as creating files outside the destination
2345+
directory.
2346+
See :ref:`tarfile-extraction-filter` for details.
2347+
In Python 3.12, use without the *filter* argument will show a
2348+
:exc:`DeprecationWarning`.
2349+
In Python 3.14, the default will switch to ``'data'``.
2350+
(Contributed by Petr Viktorin in :pep:`706`.)

0 commit comments

Comments
 (0)