From d7dd20be34006fc5f3bca92f89695633322d20c5 Mon Sep 17 00:00:00 2001 From: Omkar Kabde Date: Sat, 23 May 2026 01:58:31 +0530 Subject: [PATCH 1/2] gh-82907: Document mtime=0 for reproducible tarfile gzip output tarfile.open() already writes a fixed zero timestamp in the gzip header when mtime=0 is passed, on both the 'w:gz' and 'w|gz' paths, producing output that does not depend on the archive creation time. Document this special value, matching the existing wording in the gzip module docs. --- Doc/library/tarfile.rst | 4 +++- .../2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index 6f1e01cf5aa6ee9..9b9783d8e58013f 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -144,7 +144,9 @@ Some facts and figures: For modes ``'w:gz'`` and ``'w|gz'``, :func:`tarfile.open` accepts the keyword argument *mtime* to create a gzip archive header with that mtime. By - default, the mtime is set to the time of creation of the archive. + default, the mtime is set to the time of creation of the archive. Use + *mtime* ``0`` to generate a compressed stream that does not depend on + creation time, for reproducible output. For special purposes, there is a second format for *mode*: ``'filemode|[compression]'``. :func:`tarfile.open` will return a :class:`TarFile` diff --git a/Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst b/Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst new file mode 100644 index 000000000000000..d401606fa1a05e3 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst @@ -0,0 +1,3 @@ +Document that passing ``mtime=0`` to :func:`tarfile.open` produces a +gzip-compressed archive whose output does not depend on creation time, for +reproducible output. From 5c1db6ae57a6146163cb0f03603477836a1c1076 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 22 May 2026 23:55:12 +0300 Subject: [PATCH 2/2] Delete Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst --- .../2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst diff --git a/Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst b/Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst deleted file mode 100644 index d401606fa1a05e3..000000000000000 --- a/Misc/NEWS.d/next/Documentation/2026-05-22-13-02-35.gh-issue-82907.N0Rkfa.rst +++ /dev/null @@ -1,3 +0,0 @@ -Document that passing ``mtime=0`` to :func:`tarfile.open` produces a -gzip-compressed archive whose output does not depend on creation time, for -reproducible output.