Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89a8944

Browse files
CAM-Gerlachncoghlan
authored andcommitted
bpo-30661: Improve docs for tarfile pax change and effect on shutil (GH-12635)
The shutil archive creation helpers use the default tarfile format, so that API is also switching to use `pax` by default.
1 parent 2ea8099 commit 89a8944

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

Doc/library/shutil.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
559559

560560
The *verbose* argument is unused and deprecated.
561561

562+
.. versionchanged:: 3.8
563+
The modern pax (POSIX.1-2001) format is now used instead of
564+
the legacy GNU format for archives created with ``format="tar"``.
565+
562566

563567
.. function:: get_archive_formats()
564568

@@ -568,7 +572,7 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
568572
By default :mod:`shutil` provides these formats:
569573

570574
- *zip*: ZIP file (if the :mod:`zlib` module is available).
571-
- *tar*: uncompressed tar file.
575+
- *tar*: Uncompressed tar file. Uses POSIX.1-2001 pax format for new archives.
572576
- *gztar*: gzip'ed tar-file (if the :mod:`zlib` module is available).
573577
- *bztar*: bzip2'ed tar-file (if the :mod:`bz2` module is available).
574578
- *xztar*: xz'ed tar-file (if the :mod:`lzma` module is available).

Doc/library/tarfile.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ details.
231231

232232
The default format for creating archives. This is currently :const:`PAX_FORMAT`.
233233

234-
.. versionchanged:: 3.8
235-
The default format for new archives was changed to
236-
:const:`PAX_FORMAT` from :const:`GNU_FORMAT`.
234+
.. versionchanged:: 3.8
235+
The default format for new archives was changed to
236+
:const:`PAX_FORMAT` from :const:`GNU_FORMAT`.
237237

238238

239239
.. seealso::
@@ -813,8 +813,8 @@ Supported tar formats
813813
There are three tar formats that can be created with the :mod:`tarfile` module:
814814

815815
* The POSIX.1-1988 ustar format (:const:`USTAR_FORMAT`). It supports filenames
816-
up to a length of at best 256 characters and linknames up to 100 characters. The
817-
maximum file size is 8 GiB. This is an old and limited but widely
816+
up to a length of at best 256 characters and linknames up to 100 characters.
817+
The maximum file size is 8 GiB. This is an old and limited but widely
818818
supported format.
819819

820820
* The GNU tar format (:const:`GNU_FORMAT`). It supports long filenames and
@@ -826,14 +826,15 @@ There are three tar formats that can be created with the :mod:`tarfile` module:
826826
format with virtually no limits. It supports long filenames and linknames, large
827827
files and stores pathnames in a portable way. Modern tar implementations,
828828
including GNU tar, bsdtar/libarchive and star, fully support extended *pax*
829-
features; some older or unmaintained libraries may not, but should treat
829+
features; some old or unmaintained libraries may not, but should treat
830830
*pax* archives as if they were in the universally-supported *ustar* format.
831+
It is the current default format for new archives.
831832

832-
The *pax* format is an extension to the existing *ustar* format. It uses extra
833-
headers for information that cannot be stored otherwise. There are two flavours
834-
of pax headers: Extended headers only affect the subsequent file header, global
835-
headers are valid for the complete archive and affect all following files. All
836-
the data in a pax header is encoded in *UTF-8* for portability reasons.
833+
It extends the existing *ustar* format with extra headers for information
834+
that cannot be stored otherwise. There are two flavours of pax headers:
835+
Extended headers only affect the subsequent file header, global
836+
headers are valid for the complete archive and affect all following files.
837+
All the data in a pax header is encoded in *UTF-8* for portability reasons.
837838

838839
There are some more variants of the tar format which can be read, but not
839840
created:

Doc/whatsnew/3.8.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ shutil
300300
:func:`shutil.copytree` now accepts a new ``dirs_exist_ok`` keyword argument.
301301
(Contributed by Josh Bronson in :issue:`20849`.)
302302

303+
:func:`shutil.make_archive` now defaults to the modern pax (POSIX.1-2001)
304+
format for new archives to improve portability and standards conformance,
305+
inherited from the corresponding change to the :mod:`tarfile` module.
306+
(Contributed by C.A.M. Gerlach in :issue:`30661`.)
307+
303308

304309
ssl
305310
---

0 commit comments

Comments
 (0)