Skip to content

Commit 115adc6

Browse files
authored
fix
1 parent 1e23e46 commit 115adc6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/test/test_zipfile/_path/test_path.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ def for_name(cls, name, archive):
666666
667667
TODO: extract this functionality and re-use
668668
"""
669-
get_time = os.environ.get('SOURCE_DATE_EPOCH') or time.time()
669+
epoch = int(os.environ.get('SOURCE_DATE_EPOCH')
670+
get_time = int(epoch) if epoch is not None else time.time()
670671
self = cls(filename=name, date_time=time.gmtime(get_time)[:6])
671672
self.compress_type = archive.compression
672673
self.compress_level = archive.compresslevel

Lib/zipfile/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,8 @@ def writestr(self, zinfo_or_arcname, data,
19041904
if isinstance(data, str):
19051905
data = data.encode("utf-8")
19061906
if not isinstance(zinfo_or_arcname, ZipInfo):
1907-
get_time = int(os.environ.get('SOURCE_DATE_EPOCH'), time.time())
1907+
epoch = int(os.environ.get('SOURCE_DATE_EPOCH')
1908+
get_time = int(epoch) if epoch is not None else time.time()
19081909
zinfo = ZipInfo(filename=zinfo_or_arcname,
19091910
date_time=time.gmtime(get_time)[:6])
19101911
zinfo.compress_type = self.compression

0 commit comments

Comments
 (0)