extracting null pointer address from PyCObject with ctypes

Aaron "Castironpi" Brady castironpi at gmail.com
Fri Oct 10 12:33:44 EDT 2008


On Oct 10, 5:24 am, Gordon Allott <gordall... at gmail.com> wrote:
> Hello :)
>
> The result of various incompatibilities has left me needing to somehow
> extract the address that a null pointer is pointing to with the null
> pointer being exposed to python via PyCObject_FromVoidPtr
>
> the code that creates the PyCObject is as follows:
>     tmp = PyCObject_FromVoidPtr (info.info.x11.display, NULL);
>     PyDict_SetItemString (dict, "display", tmp);
>     Py_DECREF (tmp);
>

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 );



More information about the Python-list mailing list