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 BreamoreBoy, Viktor.Chynarov, belopolsky, benjamin.peterson, eryksun, kushal.das, lemburg, paul.moore, r.david.murray, serhiy.storchaka, steve.dower, tim.golden, vstinner, zach.ware
Date 2016-06-26.19:37:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
To resolve the crash on Windows in 2.7 requires backporting checktm(). Using asctime_s doesn't solve the problem. The CRT still calls the default invalid parameter handler, which kills the process -- as shown by the following ctypes example:

    from ctypes import *
    libc = CDLL('msvcr90')

    class tm(Structure):
        _fields_ = (('tm_sec', c_int),
                    ('tm_min', c_int),
                    ('tm_hour', c_int),
                    ('tm_mday', c_int),
                    ('tm_mon', c_int),
                    ('tm_year', c_int),
                    ('tm_wday', c_int),
                    ('tm_yday', c_int),
                    ('tm_isdst', c_int))

    libc._localtime32.restype = POINTER(tm)
    libc.asctime_s.restype = c_char_p

    t = c_int()
    lt = libc._localtime32(byref(t))
    sbuf = (c_char * 100)()

    >>> libc.asctime_s(sbuf, sizeof(sbuf), lt)
    >>> sbuf.value
    'Sun Jun 26 19:22:47 2016\n'

    >>> lt[0].tm_hour = -1
    >>> libc.asctime_s(sbuf, sizeof(sbuf), lt)

    Breakpoint 0 hit
    00000000`6b8950e4 4053            push    rbx
    0:000> k5
    Child-SP          RetAddr           Call Site
    00000000`005ef628 00000000`6b8952d4 MSVCR90!_invoke_watson
    00000000`005ef630 00000000`6b859830 MSVCR90!_invalid_parameter+0x70
    00000000`005ef670 00000000`1d1aff53 MSVCR90!asctime_s+0x2fc
    00000000`005ef6b0 00000000`1d1ae7fc _ctypes!ffi_call_AMD64+0x77
    00000000`005ef700 00000000`1d1aa4c6 _ctypes!ffi_call+0x8c
Date User Action Args
2016-06-26 19:37:05eryksunsetrecipients: + eryksun, lemburg, paul.moore, belopolsky, vstinner, tim.golden, benjamin.peterson, r.david.murray, BreamoreBoy, zach.ware, serhiy.storchaka, kushal.das, steve.dower, Viktor.Chynarov
2016-06-26 19:37:05eryksunsetmessageid: <>
2016-06-26 19:37:05eryksunlinkissue16137 messages
2016-06-26 19:37:05eryksuncreate