Title: OverflowError: mktime argument out of range after 2019
Type: behavior Stage:
Components: Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: belopolsky, corona10, lemburg, p-ganssle, psijic, terry.reedy
Priority: normal Keywords:

Created on 2021-06-13 18:02 by psijic, last changed 2021-07-16 06:09 by terry.reedy.

Messages (3)
msg395758 - (view) Author: Vyacheslav (psijic) Date: 2021-06-13 18:02
date_str = "2019-06-06 10:02:00"
    datetime_obj = datetime.strptime(date_str, "%Y-%m-%d %H:%M:%S")
    datetime_obj_utc1 = datetime_obj.replace(tzinfo=pytz.timezone("America/New_York"))
    datetime_obj_utc2 = pytz.timezone("America/New_York").localize(datetime_obj)
    print(datetime_obj_utc1, datetime_obj_utc2)
    ts1 = time.mktime(datetime_obj_utc1.timetuple())
    ts2 = time.mktime(datetime_obj_utc2.timetuple())

>>> Output:
    ts2 = int(time.mktime(datetime_obj_utc2.timetuple()))
OverflowError: mktime argument out of range

OS: Linux OpenSuse TW
msg396102 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-06-18 22:05
An exception is not a 'crash', as defined for this tracker.  3.8 only gets security fixes.  A 3.9 or 3.10 test is needed and Windows does not have pytz.
msg397600 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-07-16 06:09
The posted code is incomplete, improperly indented, and a bit jumbled with respect to prompts.  If the bug is real, it should be possible to reproduce without pytz.  I do not have it on either Windows or macOS.  Vyacheslav, can you post a better failing example?
Date User Action Args
2021-07-16 06:09:56terry.reedysetmessages: + msg397600
2021-07-16 03:51:40corona10setnosy: + corona10
2021-06-18 22:05:24terry.reedysetnosy: + terry.reedy, belopolsky, p-ganssle, lemburg
type: crash -> behavior
messages: + msg396102
2021-06-13 18:02:13psijiccreate