[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
explains this fairly well

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list