]> 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:35:56 +0000 (09:35 -0800)
committerGitHub <noreply@github.com>
Wed, 9 Feb 2022 17:35:56 +0000 (09:35 -0800)
commitb0517a12179a9fe444ca6ce1f31c307883e81c0c
treec9d12e8e3c3625f5760d141ca01baf679cb0816b
parentbde3765a3fd21e2ecf595a57998b285e3045f744
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]