extracting null pointer address from PyCObject with ctypes
Gordon Allott
gordallott at gmail.com
Fri Oct 10 23:54:29 EDT 2008
Aaron "Castironpi" Brady wrote:
>
> You are hard to follow. There is the 'cast' function, which I've had
> some success with, even in adding pointers and offsets. It took a
> look at the code for it though, and calling an undocumented version of
> it. I can post that later if you don't have luck the same. You can
> write extension modules to do that as well, and there's always a
> Google search which personally I forget half the time too. Last, you
> haven't mentioned an attempt with PyCObject_AsVoidPtr yet:
>
> void* PyCObject_AsVoidPtr(PyObject* self)
> Return the object void * that the PyCObject self was created with.
>
> Where does that get you?
> --
> http://mail.python.org/mailman/listinfo/python-list
sorry yes you were right, I was reading PyCObject_AsVoidPtr as
PyCObject_FromVoidPtr :)
using AsVoidPtr is a little confusing, this is the code I am using:
display = pygame.display.get_wm_info()['display']
pyobj = py_object(display)
ref = pointer(pyobj)
print pythonapi.PyCObject_AsVoidPtr(ref)
it produces the following traceback:
Traceback (most recent call last):
File "pygametest.py", line 125, in <module>
app = PyGameOGREApp()
File "pygametest.py", line 33, in __init__
self._createWindow(width, height, fullscreen)
File "pygametest.py", line 64, in _createWindow
print pythonapi.PyCObject_AsVoidPtr(ref)
TypeError: PyCObject_AsVoidPtr with non-C-object
- I think that's because its a pointer to the ctypes py_object() rather
than the PyCObject we are dealing with but I have no idea how to create
a pointer to that.
--
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/20081011/e0b6f972/attachment-0001.sig>
More information about the Python-list
mailing list