Hi everyone, I have the following problem: an abstract base class A that is exported to python and another class, let's call it L, that is little more than a glorified vector of A's with a few convenience functions. The constructor of L is passed a std::vector<A*>. Now I would like to export L to Python with the following conditions: 1. The __init__ function of L should take a Python list containing sub classes of A that is automatically converted to a vector of A pointers 2. The L instance takes ownership of the A's (they are deleted in the destructor)
Since I have to write a wrapper for L anyway (for virtual functions with default implementation), I tried giving the wrapper class a constructor like so: LWrapper(boost::python::object o) { boost::python::list listOfAs = extract<boost::python::list>(o); try { bool is_ok = true; while(is_ok) { extract<A*> a(listOfAs.pop(0)) if(a.check()) { vectorOfAs.push_back(a()) // vectorOfAs is a protected class member of L } else { is_ok = false; } } } catch(exception &e) { std::cerr << "Oops!"; } } But this crashes with "glibc dected [...] free(): invalid pointer [...]". So. How would I actually go about doing this? Thanks in advance, Benjamin Kloster _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig