extracting null pointer address from PyCObject with ctypes

Aaron "Castironpi" Brady castironpi at gmail.com
Fri Oct 10 20:23:03 EDT 2008


On Oct 10, 4:16 pm, Gordon Allott <gordall... at gmail.com> wrote:
> Aaron "Castironpi" Brady wrote:
> > 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.
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> I have a hard time following that, if using ctypes you used PyDLL to
> call PyCObject_AsVoidPtr on the PyCObject I already have surely it would
>  give me back a pointer (void for sake of simplicity) but it would be a
> pointer to a new PyCObject and thus calling result.value on it would
> only return the memory address of the new PyCObject?
> --
> Gord Allott (gordall... at gmail.com)
>
>  signature.asc
> < 1KViewDownload


Yes, well said.  But no, not true, not necessarily.  You can choose/
change return types with your code.  If the call is defined already
and you can't change the return, just define a new one that returns
long.



More information about the Python-list mailing list