extracting null pointer address from PyCObject with ctypes

Gordon Allott gordallott at gmail.com
Fri Oct 10 06:24:54 EDT 2008


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

which is exposed to python via a dictionary (the 'display' key). python
identifies that its a PyCObject but doesn't give any way to expose the
functionality. Essentially I am after the address that the void pointer
'info.info.x11.display' points to (as a long type)

As far as I can tell ctypes will only expose the pyObject type to me and
not actually let me deal with the data I am after, but being rather new
to ctypes I'm not sure weather this is correct.

-- 
Gord Allott (gordallott at gmail.com)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20081010/0cf51546/attachment.sig>


More information about the Python-list mailing list