j.reid at mail.cryst.bbk.ac.uk
Fri Jun 16 09:55:27 CEST 2006
David Abrahams wrote:
> John Reid <johnbaronreid at netscape.net> writes:
>>I'm trying to call a python function from C++. I pass the function to
>>C++ as a boost::python::object. I can call functions with no arguments,
>>when I try to pass a C++ created object as an argument I get the
>>Traceback (most recent call last):
>> File "python/test_python.py", line 8, in ?
>> d.connect_new_deal_slot_py_2( f )
>>TypeError: No to_python (by-value) converter found for C++ type: class
> Actually that would be namespacename::classname. It's a C++ class
> name, most probably of the return type of the C++ function
> implementing your connect_new_deal_slot_py_2 method. Another
> possibility is that it's the name of a C++ class of which you're
> passing an instance to f inside that C++ function implementing
> connect_new_deal_slot_py_2. Either way, you haven't wrapped that C++
I was pretty sure I had wrapped it. Was that not what I was doing with
the following code?
class_< test, noncopyable >( "test" )
.def( "connect_slot", &test::connect_slot_py )
Anyhow I tracked the problem down a little more and found out it did not
like the noncopyable base class. Without this everything was OK. From
the documentation it wasn't clear that this would make it difficult for
me to pass C++ objects to python. I'm guessing there is a way to do this
even with the noncopyable base class but I couldn't work it out.
It is clear that I had some problems understanding what was going wrong.
I'm not really sure if that was a problem with me, the error messages or
Thanks for your help.
More information about the Cplusplus-sig