]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-45863: tarfile: don't zero out header fields unnecessarily (GH-29693)
authorJoshua Root <jmr@macports.org>
Wed, 9 Feb 2022 17:06:19 +0000 (04:06 +1100)
committerGitHub <noreply@github.com>
Wed, 9 Feb 2022 17:06:19 +0000 (18:06 +0100)
commitbf2d44ffb06e8f49aacc6b1c140a6717df5cf897
tree3a800a1bc6bf17b549cb2d0e43ff0046835a0baa
parentc0a5ebeb1239020f2ecc199053bb1a70d78841a1
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.
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]