[C++-sig] Multiple-inheritance problem
Piotr Jaroszyński
p.jaroszynski at gmail.com
Sat Oct 6 18:59:23 CEST 2007
Hello,
Seems that when one creates a Python class, which multiple-inherits from
classes exposed by boost.python then it can be only converted(casted) to the
first class in the inheritance list. Simple example code follows.
C++:
#include <boost/python.hpp>
namespace bp = boost::python;
struct A { };
struct B { };
void test_A(const A &) { }
void test_B(const B &) { }
BOOST_PYTHON_MODULE(multiple_inheritance)
{
bp::def("test_A", &test_A);
bp::def("test_B", &test_B);
bp::class_<A>("A", bp::init<>());
bp::class_<B>("B", bp::init<>());
}
Python:
class C(A, B):
pass
test_A(C())
test_B(C())
And I get:
Traceback (most recent call last):
File "./multiple_inheritance.py", line 10, in <module>
test_B(C())
Boost.Python.ArgumentError: Python argument types in
multiple_inheritance.test_B(C)
did not match C++ signature:
test_B(B)
Am I missing something or is it a known problem? Any workaround if so?
--
Best Regards,
Piotr Jaroszyński
More information about the Cplusplus-sig
mailing list