Eryk Sun added the comment:

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

----------
components: +Library (Lib), Windows
nosy: +belopolsky, eryksun, paul.moore, steve.dower, tim.golden, tim.peters, 
zach.ware
type:  -> behavior
versions: +Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30684>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to