Author theller
Recipients theller
Date 2018-02-01.19:54:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
ctypes Structure fields of type c_char_p or c_wchar_p used to accept strings with embedded null characters.  I noticed that Python 3.6.4 does refuse them.  It seems this has been changed in recent version(s).

There ARE use-cases for this:  The Windows-API OPENFILENAME structure is one example.  The Microsoft docs for the lpstrFilter field:


    Type: LPCTSTR

    A buffer containing pairs of null-terminated filter strings. The last string in the buffer must be terminated by two NULL characters.

I have attached a simple script which demonstrates this new behaviour; the output with Python 3.6.4 is this:

Traceback (most recent call last):
  File "", line 8, in <module>
    t.unicode = u"foo\0bar"
ValueError: embedded null character
Date User Action Args
2018-02-01 19:54:50thellersetrecipients: + theller
2018-02-01 19:54:50thellersetmessageid: <>
2018-02-01 19:54:50thellerlinkissue32745 messages
2018-02-01 19:54:49thellercreate