New submission from Thomas Heller <thel...@ctypes.org>: 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: """ lpstrFilter 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 "nullchars.py", line 8, in <module> t.unicode = u"foo\0bar" ValueError: embedded null character ---------- components: ctypes files: nullchars.py keywords: 3.6regression messages: 311462 nosy: theller priority: normal severity: normal status: open title: ctypes string pointer fields should accept embedded null characters versions: Python 3.6 Added file: https://bugs.python.org/file47420/nullchars.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32745> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com