Skip to content

gh-82907: Document mtime=0 for reproducible tarfile gzip output#150269

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
omkar-334:gh-82907-tarfile-mtime0-doc
May 22, 2026
Merged

gh-82907: Document mtime=0 for reproducible tarfile gzip output#150269
serhiy-storchaka merged 3 commits into
python:mainfrom
omkar-334:gh-82907-tarfile-mtime0-doc

Conversation

@omkar-334
Copy link
Copy Markdown
Contributor

@omkar-334 omkar-334 commented May 22, 2026

tarfile.open() takes an mtime argument for gzip writing, and passing mtime=0 writes a zero timestamp into the gzip header, so the output doesn't depend on when the archive was created.

That value wasn't mentioned in the docs, even though the gzip module documents the same thing. This adds a sentence to the tarfile.open() docs, matching the gzip wording.

this pr fixes #82907 and affects only docs

cc @serhiy-storchaka

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.
@omkar-334
Copy link
Copy Markdown
Contributor Author

I noticed the mtime parameter (added in #75707) has no .. versionchanged:: 3.15 note
in the docs..should this be added?

@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32816312 | 📁 Comparing d91734f against main (4e3ead9)

  🔍 Preview build  

2 files changed
± library/tarfile.html
± whatsnew/changelog.html

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Such small docs changes do not need a NEWS entry.

@serhiy-storchaka serhiy-storchaka added skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels May 22, 2026
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) May 22, 2026 20:57
@serhiy-storchaka serhiy-storchaka merged commit 9df2b6c into python:main May 22, 2026
41 of 42 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs May 22, 2026
@miss-islington-app
Copy link
Copy Markdown

Thanks @omkar-334 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app
Copy link
Copy Markdown

Sorry, @omkar-334 and @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 9df2b6ccc719b0bc0167da65b72b57f9da39398b 3.14

@miss-islington-app
Copy link
Copy Markdown

Sorry, @omkar-334 and @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 9df2b6ccc719b0bc0167da65b72b57f9da39398b 3.13

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 22, 2026

GH-150271 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 22, 2026
@serhiy-storchaka serhiy-storchaka removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 22, 2026
serhiy-storchaka pushed a commit that referenced this pull request May 22, 2026
GH-150269) (GH-150271)

(cherry picked from commit 9df2b6c)

Co-authored-by: Omkar Kabde <omkarkabde@gmail.com>
@serhiy-storchaka serhiy-storchaka removed their assignment May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add equivalent of gzip -n (omit timestamp and original file name) to tarfile module's auto-compression support

2 participants