]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-45863: tarfile: don't zero out header fields unnecessarily (GH-29693)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 9 Feb 2022 17:31:12 +0000 (09:31 -0800)
committerGitHub <noreply@github.com>
Wed, 9 Feb 2022 17:31:12 +0000 (09:31 -0800)
commit42f87d435ebe4f2834c8fd0b4ce38f0b1627f3ed
treeba6d119fa9182fa75f0b447f93e9bff076e52531
parentd29bbc22b08551afce24e933f43bfcb6e980cb08
bpo-45863: tarfile: don't zero out header fields unnecessarily (GH-29693)

Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
(cherry picked from commit bf2d44ffb06e8f49aacc6b1c140a6717df5cf897)

Co-authored-by: Joshua Root <jmr@macports.org>
Lib/tarfile.py
Lib/test/test_tarfile.py
Misc/NEWS.d/next/Library/2022-02-09-00-53-23.bpo-45863.zqQXVv.rst [new file with mode: 0644]