[issue36792] [Windows] time: crash on formatting time with de_DE locale

Jeremy Kloth report at bugs.python.org
Mon May 6 12:35:05 EDT 2019


Jeremy Kloth <jeremy.kloth+python-tracker at gmail.com> added the comment:

Oops, I forgot to add in my snippet, the setlocale() call prior to calling the C strftime() function.  So an updated test:

import locale
locale.setlocale(locale.LC_ALL, 'de_DE')
import ctypes, struct
libc = ctypes.cdll.msvcrt
buf = ctypes.create_string_buffer(1024)
tm = struct.pack('9i', 2019, 5, 6, 9, 50, 4, 0, 126, 1)
print('count:', libc.strftime(buf, 1024, b'%Z', tm))
print('value:', buf.value)
wbuf = ctypes.create_unicode_buffer(1024)
print('count:', libc.wcsftime(wbuf, 1024, '%Z', tm))
print('value:', wbuf.value)
print('count:', libc.mbstowcs(wbuf, buf, 1024))
print('value:', wbuf.value)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36792>
_______________________________________


More information about the Python-bugs-list mailing list