Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

mktime resulting in OverflowError: mktime argument out of range

$
0
0

When attempting to get a time using mktime, I get a overflow exception. This occurs on a Debian docker image, but not on my host machine:

docker pull python:3.9.7

https://hub.docker.com/layers/library/python/3.9.7/images/sha256-9d7d2a6ce11fe5a12c74f81b860f5142fd91192427ece0b566c4fb962353325e?context=explore

pytz==2021.3

Here's a toy example:

import datetimeimport timeimport pytzts = 1655043357tz = 'Canada/Eastern'utc_time = datetime.datetime.now(tz=pytz.utc)tz = pytz.timezone(tz)tz_aware = datetime.datetime.now(tz=tz)time.mktime(utc_time.timetuple()) # No exceptiontime.mktime(tz_aware.timetuple()) # <----Results in exception

Exception:

Traceback (most recent call last):  File "/home/toy_example.py", line 15, in <module>    time.mktime(tz_aware.timetuple())OverflowError: mktime argument out of range

There is no exception when running on my host machine and works as expected. Any idea why that's happening?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>