I'm using win32gui.PyGetBufferAddressAndLen to pass the address & length of a marshalled object as the wparam / lparam of a windows message. Something like this:

address, length = \
 win32gui.PyGetBufferAddressAndLen (buffer (marshal.dumps (message)))
PostMessage (self.hwnd, self.WM_PROGRESS_MESSAGE, length, address)

where "message" here is actually a unicode object. At the other end, I'm unpacking the message with PyGetString:

message = marshal.loads (win32gui.PyGetString (lparam, wparam))


Obviously, these two code fragments occur in two completely
different places. (In two separate threads, in fact). What
I'm entirely unsure about is the safety of this from the
point of view of the object references. I'm fairly shaky on
the Python C-API so altho' I've looked at the implementation
of those functions I can't make out whether any references to
the data in the buffer is being held.

The symptom is that, sometimes, I get garbage out when unmarshalling
from the message, which suggests to me that the memory *is* being
reallocated.

Can anyone enlighten me?

Thanks

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to