[C++-sig] Returning PyObject and return_internal_reference<>

Václav Haisman vaclav.haisman at eccam.com
Fri Feb 13 15:33:26 CET 2009

I am trying to return a new Python buffer that is a view to internals of
my Message object. My understanding is that in such case, I should use
return_internal_reference<> to make the return value hold reference to
the Message class because of this bit of PyBuffer_FromMemory() docs:
"The caller is responsible for ensuring that the memory buffer, passed
in as ptr, is not deallocated while the returned buffer object exists."

The problem is that whatever approach I could think of results into
uncompilable code. (See the attached file.) I am using Boost 1.37.0.

Is there any other way that I can do this?

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.cpp.txt
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090213/07d0a414/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2575 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090213/07d0a414/attachment.bin>

More information about the Cplusplus-sig mailing list