extracting null pointer address from PyCObject with ctypes
Aaron "Castironpi" Brady
castironpi at gmail.com
Fri Oct 10 19:32:22 CEST 2008
On Oct 10, 12:04 pm, Gordon Allott <gordall... at gmail.com> wrote:
> Aaron "Castironpi" Brady wrote:
> > Did you try:
> > tmp= PyLong_FromLong( ( long ) info.info.x11.display );
> > PyDict_SetItemString (dict, "display", tmp);
> > Py_DECREF (tmp);
> > Or also try:
> > PyCObject_AsVoidPtr( tmp );
> > --
> the problem is that I can't edit the C code - well I can and might
> submit a patch to the project but I also need a solution that works from
> the python side of things.
I see. If I understand, you have a PyCObject in a dictionary.
Look at the 'ctypes' module and try calling PyCObject_AsVoidPtr. Its
return type should be 'c_void_p', and you can use 'result.value' to
get the original pointer.
More information about the Python-list