This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Jonathan Hsu
Recipients Ard Kuijpers, Jonathan Hsu, SilentGhost, Snidhi, Windson Yang, belopolsky, p-ganssle
Date 2020-03-24.05:43:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585028595.71.0.575387949851.issue36759@roundup.psfhosted.org>
In-reply-to
Content
This exception is raised because astimezone() ends up calling time.localtime() to determine the appropriate time zone. If the datetime object has a pre-epoch value, it passes a negative timestamp to time.localtime(). On Windows, time.localtime() does not accept values greater than 0 (more discussion in issue #35796).

This is the minimal code required to reproduce the error:

from datetime import datetime
datetime(1969, 1, 1).astimezone()

Without the ability to ascertain the time zone with localtime(), I'm not sure if the time zone can be accurately determined. It's not clear what the proper behavior is. Maybe raise a ValueError?

PEP 615 proposes to include the IANA tz database, which would negate the need for a system call. Should we wait for this PEP before fixing this issue? Thoughts?
History
Date User Action Args
2020-03-24 05:43:15Jonathan Hsusetrecipients: + Jonathan Hsu, belopolsky, SilentGhost, p-ganssle, Snidhi, Windson Yang, Ard Kuijpers
2020-03-24 05:43:15Jonathan Hsusetmessageid: <1585028595.71.0.575387949851.issue36759@roundup.psfhosted.org>
2020-03-24 05:43:15Jonathan Hsulinkissue36759 messages
2020-03-24 05:43:15Jonathan Hsucreate