[C++-sig] Chaining methods in C++ and Python
David Abrahams
dave at boost-consulting.com
Wed Mar 5 12:36:00 CET 2003
Alexey Goldin <Alexey.Goldin at jpl.nasa.gov> writes:
> Here is a small test case which seems to reproduce the problem --- see attached files.
>
> Build test.so from test.cpp, then run python t.py
>
>
> Thanks!
This is a simple issue of lifetime management. The C++ 'a' objects
created in mk_tst are owned by their corresponding Python objects,
which get destroyed when mk_tst exits. The pointers you have stored
in your 'tst' object are dangling thereafter.
The Introduction section at
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/doc/v2/with_custodian_and_ward.html#introduction
explains this fairly well
HTH,
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list