Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/test/test_zipfile/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ def test_write_with_source_date_epoch(self):

with zipfile.ZipFile(TESTFN, "r") as zf:
zip_info = zf.getinfo("test_source_date_epoch.txt")
get_time = time.localtime(int(os.environ['SOURCE_DATE_EPOCH']))[:6]
get_time = time.gmtime(int(os.environ['SOURCE_DATE_EPOCH']))[:6]
# Compare each element of the date_time tuple
# Allow for a 1-second difference
for z_time, g_time in zip(zip_info.date_time, get_time):
Expand Down
9 changes: 6 additions & 3 deletions Lib/zipfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,12 @@ def _for_archive(self, archive):
Return self.
"""
# gh-91279: Set the SOURCE_DATE_EPOCH to a specific timestamp
epoch = os.environ.get('SOURCE_DATE_EPOCH')
get_time = int(epoch) if epoch else time.time()
self.date_time = time.localtime(get_time)[:6]
source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH')

if source_date_epoch:
self.date_time = time.gmtime(int(source_date_epoch))[:6]
else:
self.date_time = time.localtime(time.time())[:6]

self.compress_type = archive.compression
self.compress_level = archive.compresslevel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zip: On reproducible builds, ZipFile longer pulls in local environment timezone when writing file datetimes
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
zip: On reproducible builds, ZipFile longer pulls in local environment timezone when writing file datetimes
zip: On reproducible builds, ZipFile uses UTC instead of the local time when writing file datetimes to avoid underflows.

Loading