[C++-sig] Extracting and returning a c++ object from python and garbage collection
Roman Yakovenko
roman.yakovenko at gmail.com
Wed Aug 20 20:18:15 CEST 2008
On Wed, Aug 20, 2008 at 1:03 AM, William Ladwig <wladwig at wdtinc.com> wrote:
> I looked at the Py++ code and tried it out (it's similar to how I tried it originally) and it also throws a "dangling pointer" exception from the interpreter.
Interesting, I've got other errors.
Using Visual Studio 2003, I got warning during compilation and
TypeError during runtime, which says, that Boost.Python is not able to
construct rvalue, std::auto_ptr< your class >, from the Python object.
Using gcc 4.2.3, on Ubuntu the generated code didn't compiled and when
I fixed it, than everything was fine and worked as expected
I attached source code, "fixed" generated code and small tester.
What is your environment?
Any way, it seems that I found solution. The only change was to
extract std::auto_ptr<> as is, by value, from Python object.
Let me know, if this really solves your problem, I will fix Py++.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: return_auto_ptr_to_be_exported.hpp
Type: text/x-csrc
Size: 1265 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080820/1a8af2d2/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: return_auto_ptr.cpp
Type: text/x-c++src
Size: 3964 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080820/1a8af2d2/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x.py
Type: text/x-python
Size: 573 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080820/1a8af2d2/attachment.py>
More information about the Cplusplus-sig
mailing list