[C++-sig] Can ownership of a wrapped C++ object be transferred between python objects?
Bruce Lowery
bruce_lowery at yahoo.com
Tue Feb 4 21:09:15 CET 2003
Part of an API that I'm wrapping goes something like this:
struct A {}; struct B { void insert( A* ); }
where B::add() takes ownership of the pointer passed to it.
However:
a = mod.A()
b = mod.B()
b.add( a )
del a
del b
# python interpreter crashes
# later due to memory corruption.
Even binding the lifetime of 'a' to 'b' via with_custodian_and_ward doesn't
prevent the python object 'a' from ultimately trying to delete the object it's
pointing to (right? - I tried anyway and didn't see any improvement).
Is there a way to accomplish a 'transfer-of-ownership' of a wrapped C++ object?
Bruce Lowery
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
More information about the Cplusplus-sig
mailing list