file/zip: clamp timestamps to supported range #4451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, timestamps outside the range supported by the Zip format would lead to an error from
integer->integer-bytes
.The Info-ZIP
zip
utility andlibarchive
(at least as used by Ark) seem to implicitly clamp timestamps this way. Python'szipfile.ZipFile
raises an error by default when timestamps are out of range, but it clamps timestamps this way when called withstrict_timestamps=False
.This probably needs some tests.
Does it also need a history note?
I could imagine adding a
#:strict-timestamps?
option, but I think the default should be permissive: Python's strict default seems to be mostly a source of confusing errors. And at that point, it seemed better to hold off on adding a keyword until/unless someone actually wants one.One way timestamps before 1980 happen is when translating the POSIX time 0 (1970-01-01T00:00:00Z), which is used by some tools that try to normalize extraneous metadata.