-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
Description
In a project that aims to emit reproducible archives, tar.xz archives were working as expected, but zip archives were ending up with timestamp discrepancies between local builds in AEST (UTC+10) and CI builds in UTC.
I eventually tracked this down to differing timestamp handling conventions in tarfile
and zipfile
(these conventions aren't unique to Python, so we can't readily eliminate the discrepancy, we can only document it):
tarfile
uses the timestamps as they are, so if the filesystem stores timestamps in UTC (as most common filesystems other than FAT/FAT32/VFAT will do), they will be added to the file as UTC. If the filesystem stores local time, it will still be used without modification, but will probably be interpreted as UTC when the archive is extractedzipfile
explicitly interprets the filesystem timestamps withtime.localtime
, so they will be added to the file as local time by default. If the filesystem already uses local time, the timezone offset will be applied a second time (potentially resulting in a stored modification time in the future for local timezones with a positive offset from UTC)
tarfile
has an additional timezone related complication in that some compression formats (at least gzip
) include a file creation time header: #75707
Discourse thread: https://discuss.python.org/t/tarfile-vs-zipfile-timezone-discrepancy-in-handling-modification-times/61016
emmatyping
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
Projects
Status
No status