Feb-02-2017, 09:13 AM
Hi,
I'm able to create a c_void_p PyObject like so
I would expect doing something like this:
According to ctypes doc https://docs.python.org/3/library/ctypes.html (16.16.1.4. Fundamental data types) c_void_p type corresponds to Python type "int or None". So it looks like I get none.
So how can I possibly convert my c_void_p PyObject to a long PyObject in this case?
Thanks,
-Damien
I'm able to create a c_void_p PyObject like so
PyObject* ctypes_mod = PyImport_ImportModule("ctypes"); PyObject* c_void_p = PyObject_GetAttrString(ctypes_mod, "c_void_p"); PyObject* p = PyObject_CallFunction(c_void_p, "O", PyLong_FromVoidPtr(my_void*));Now I need to get my pointer back from python
I would expect doing something like this:
PyLong_AsVoidPtr(p)But it fails with class TypeError: an integer is required.
According to ctypes doc https://docs.python.org/3/library/ctypes.html (16.16.1.4. Fundamental data types) c_void_p type corresponds to Python type "int or None". So it looks like I get none.
So how can I possibly convert my c_void_p PyObject to a long PyObject in this case?
Thanks,
-Damien