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 eryksun
Recipients belopolsky, eryksun, lazka, paul.moore, steve.dower, tim.golden, tim.peters, zach.ware
Date 2017-06-16.14:34:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1497623641.55.0.710813956289.issue30684@psf.upfronthosting.co.za>
In-reply-to
Content
This is due to computing the PEP 495 fold in the function datetime_from_timet_and_us in Modules/_datetimemodule.c. It computes the local time for (timet - max_fold_seconds), which is negative for timestamps less than max_fold_seconds (86400). It's documented that localtime_s [1] fails for negative time values. For example:

    0:000> kc 6
    Call Site
    python36_d!localtime_s
    python36_d!_PyTime_localtime
    python36_d!local
    python36_d!datetime_from_timet_and_us
    python36_d!datetime_from_timestamp
    python36_d!datetime_fromtimestamp

Dereference the time_t* arg (-86400):

    0:000> ?? *(int64_t *)@rdx
    int64 0n-86400

Print the errno_t return value (0x16 is EINVAL):

    0:000> pt; r rax
    rax=0000000000000016

[1]: https://msdn.microsoft.com/en-us/library/a442x3ye.aspx
History
Date User Action Args
2017-06-16 14:34:01eryksunsetrecipients: + eryksun, tim.peters, paul.moore, belopolsky, tim.golden, zach.ware, steve.dower, lazka
2017-06-16 14:34:01eryksunsetmessageid: <1497623641.55.0.710813956289.issue30684@psf.upfronthosting.co.za>
2017-06-16 14:34:01eryksunlinkissue30684 messages
2017-06-16 14:34:01eryksuncreate