Boost logo

Boost Users :

Subject: Re: [Boost-users] [python] converting C++ object to PyObject
From: Ravi (lists_ravi_at_[hidden])
Date: 2011-08-08 00:21:12


On Friday, July 29, 2011 05:48:32 AM Johan Råde wrote:
> When I run the following code
>
> C++:
>
> #include<boost/noncopyable.hpp>
> #include<boost/python.hpp>
>
> using boost::noncopyable;
> using namespace boost::python;
>
> class X : noncopyable {};
>
> PyObject* f()
> {
> return api::object(new X).ptr();
> }
>
> BOOST_PYTHON_MODULE(Foo)
> {
> class_<X, noncopyable>("X");
> def("f", &f);
> }
>
> Python:
>
> import Foo
> Foo.f()
>
>
> then an exception, with the following error string, is thrown from the
> api::object constructor:
>
> TypeError: No to_python (by-value) converter found for C++ type:
> class X
>
> Am I using api::object incorrectly, or should I not use api::object at
> all but do something completely different?

As far as I can tell, the above should work. Could you please file a ticket on
trac?

Ravi


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net