You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If building on a reproducible environment such as NixOS, and your local timezone has a negative UTC offset, a large number of the ZipFile tests fail due to a underflow of the DOS date value:
Zips by default store file timestamps as a DOS date and a DOS time, They are unsigned and 16-bits wide.
In recent ZipFile updates, SOURCE_DATE_EPOCH is read from if it exists. If it exists, it's not taken as UTC and is instead converted to the system's local time:
# gh-91279: Set the SOURCE_DATE_EPOCH to a specific timestamp
epoch=os.environ.get('SOURCE_DATE_EPOCH')
get_time=int(epoch) ifepochelsetime.time()
self.date_time=time.localtime(get_time)[:6]
If your local time has a negative UTC offset, this ends up subtracting from the minimum possible DOS date value, which underflows to what would be a negative DOS date.
In tests, ValueError is raised anytime a file is written to a ZipFile, because the DOS date under reproducible systems is not in the range 0 <= date <= 65535.
Bug report
Bug description:
Background
SOURCE_DATE_EPOCHspecifically.Bug
If building on a reproducible environment such as NixOS, and your local timezone has a negative UTC offset, a large number of the ZipFile tests fail due to a underflow of the DOS date value:
SOURCE_DATE_EPOCHto315532800(1980-01-01 00:00:00 UTC) to specifically support programs and standards assuming DOS time (stdenv: set SOURCE_DATE_EPOCH to a value python supports NixOS/nixpkgs#89794), of which zip is one.SOURCE_DATE_EPOCHis read from if it exists. If it exists, it's not taken as UTC and is instead converted to the system's local time:cpython/Lib/zipfile/__init__.py
Lines 625 to 628 in 8d490b3
ValueErroris raised anytime a file is written to a ZipFile, because the DOS date under reproducible systems is not in the range0 <= date <= 65535.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs