Skip to content

[3.15] gh-133998: Fix tarfile error on out-of-range mtime in streaming gzip mode (GH-151828) - #159158

Merged
vstinner merged 1 commit into
python:3.15from
miss-islington:backport-c6c0608-3.15
Oct 11, 2026
Merged

vstinner merged 1 commit into
python:3.15from
miss-islington:backport-c6c0608-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

tarfile.open(..., "w|gz", mtime=...) packed mtime into the gzip header's
32-bit field with no range check, so a value < 0 or >= 2**32 raised
struct.error. Mirror the merged gzip fix: substitute 0 for out-of-range
values and coerce to int (RFC 1952), so floats and out-of-range system
clocks behave the same as in gzip and the non-streaming "w:gz" path
(which already delegates to GzipFile and was unaffected).
(cherry picked from commit c6c0608)

Co-authored-by: Harjoth Khara harjoth.khara@gmail.com
Co-authored-by: Victor Stinner vstinner@python.org

… gzip mode (pythonGH-151828)

tarfile.open(..., "w|gz", mtime=...) packed mtime into the gzip header's
32-bit field with no range check, so a value < 0 or >= 2**32 raised
struct.error. Mirror the merged gzip fix: substitute 0 for out-of-range
values and coerce to int (RFC 1952), so floats and out-of-range system
clocks behave the same as in gzip and the non-streaming "w:gz" path
(which already delegates to GzipFile and was unaffected).
(cherry picked from commit c6c060843b7635b5a1f82e0983d803eb0d185b5d)

Co-authored-by: Harjoth Khara <harjoth.khara@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner
vstinner merged commit d4b8d66 into python:3.15 Oct 11, 2026
58 checks passed
@miss-islington
miss-islington deleted the backport-c6c0608-3.15 branch October 11, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants