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.

classification
Title: Cannot cast '\0' to c_void_p
Type: behavior Stage:
Components: ctypes Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Ilya.Kulakov
Priority: normal Keywords:

Created on 2017-11-15 21:01 by Ilya.Kulakov, last changed 2022-04-11 14:58 by admin.

Messages (3)
msg306307 - (view) Author: Ilya Kulakov (Ilya.Kulakov) * Date: 2017-11-15 21:01
Happens on 3.6.3 only:

>>> import ctypes
>>> ctypes.cast('\0', ctypes.c_void_p)
ctypes.ArgumentError: argument 1: <class 'ValueError'>: embedded null character
msg306323 - (view) Author: Ilya Kulakov (Ilya.Kulakov) * Date: 2017-11-16 00:15
That's the change that introduced the bug: https://github.com/python/cpython/pull/2285
msg306325 - (view) Author: Ilya Kulakov (Ilya.Kulakov) * Date: 2017-11-16 01:38
I have fixed that problem by ensuring that ctypes-facing code passes bytes, not strings.
History
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76222
2017-11-16 01:38:43Ilya.Kulakovsetmessages: + msg306325
2017-11-16 00:15:40Ilya.Kulakovsetmessages: + msg306323
2017-11-15 21:01:06Ilya.Kulakovcreate