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
{{ message }}
Repository navigation
bullseye images has issue with mktime OverflowError #815
Sorry for the delay! I can't seem to reproduce: 😅 (maybe it was fixed in the meantime?)
$ docker run -it --rm python:bullseye bashUnable to find image 'python:bullseye' locallybullseye: Pulling from library/pythond1da99c2f148: Already exists 577ff23cfe55: Already exists c7b1e60e9d5a: Already exists beefab36cbfe: Already exists fa938ef3feea: Pull complete b42187d88e49: Pull complete c7bef4d98a8c: Pull complete f521a6ee79f8: Pull complete Digest: sha256:ea707c4da86081316413f76c2c8726886742ff6aedca71a9f81bfb4d55ecd396Status: Downloaded newer image for python:bullseyeroot@fef26b257d05:/# pip install pytzCollecting pytz Obtaining dependency information for pytz from https://files.pythonhosted.org/packages/32/4d/aaf7eff5deb402fd9a24a1449a8119f00d74ae9c2efa79f8ef9994261fc2/pytz-2023.3.post1-py2.py3-none-any.whl.metadata Downloading pytz-2023.3.post1-py2.py3-none-any.whl.metadata (22 kB)Downloading pytz-2023.3.post1-py2.py3-none-any.whl (502 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 502.5/502.5 kB 13.7 MB/s eta 0:00:00Installing collected packages: pytzSuccessfully installed pytz-2023.3.post1WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv[notice] A new release of pip is available: 23.2.1 -> 23.3.2[notice] To update, run: pip install --upgrade piproot@fef26b257d05:/# pythonPython 3.12.1 (main, Dec 9 2023, 00:30:59) [GCC 10.2.1 20210110] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from datetime import datetime>>> import time>>> import pytz>>> tz=pytz.timezone('America/New_York')>>> nytime= datetime.utcnow().astimezone(tz)<stdin>:1: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).>>> time.mktime(nytime.timetuple())1702924216.0
However, if using a value when daylight saving time is in effect (EDT), it blows up:
nytime = datetime(2024, 6, 1).astimezone(tz).timetuple()
print(f"time.mktime(nytime) = {time.mktime(nytime)}")
...
OverflowError: mktime argument out of range
Aha, even better, it also fails on Debian's Python in bullseye, so it's something about bullseye specifically that's causing this (not something we did):
$ docker run -it --rm --pull=always debian:bullseye-slimbullseye-slim: Pulling from library/debian728328ac3bde: Already exists Digest: sha256:0e75382930ceb533e2f438071307708e79dc86d9b8e433cc6dd1a96872f2651dStatus: Downloaded newer image for debian:bullseye-slimroot@15b362c1a62e:/# apt-get update -qqroot@15b362c1a62e:/# apt-get install -yqq python3...root@15b362c1a62e:/# python3Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from datetime import datetime>>> import time>>> time.mktime(time.struct_time(sequence=(2000, 11, 30, 0, 0, 0, 3, 335, 1)))Traceback (most recent call last): File "<stdin>", line 1, in <module>OverflowError: mktime argument out of range
Activity
tianon commentedon Dec 18, 2023
Sorry for the delay! I can't seem to reproduce: 😅 (maybe it was fixed in the meantime?)
LaurentGoderre commentedon Jan 18, 2024
Tried different arches and couldn't reproduce either.
vly-ginger commentedon Jun 4, 2024
I was able to repro with Python 3.7.13 on bullseye (
python:3.7.13-bullseyeandpython:3.7.13-slim-bullseye) when the datetime is in daylight savings.Firstly, staying with the example of Eastern Time, when we are in EST, things work fine:
However, if using a value when daylight saving time is in effect (EDT), it blows up:
LaurentGoderre commentedon Jun 4, 2024
That snippet actually ends up being reducible to the following
LaurentGoderre commentedon Jun 4, 2024
This seems to be a bug withastimezonewhere it returns1fortm_isdstwhen it can only be0or-1The docs says that value
1fortm_isdstis valid but that is what is causing the issue inmktimeLaurentGoderre commentedon Jun 4, 2024
Hacky way would be to do:
tianon commentedon Jun 4, 2024
It also seems to fail only on bullseye -- the newer bookworm images are also fine 🤔
tianon commentedon Jun 4, 2024
Aha, even better, it also fails on Debian's Python in bullseye, so it's something about bullseye specifically that's causing this (not something we did):