Boost logo

Boost Users :

Subject: Re: [Boost-users] [python] converting C++ object to PyObject
From: Johan Råde (johan.rade_at_[hidden])
Date: 2011-07-29 08:48:32

On 2011-07-29 13:29, Johan Råde wrote:
> On 2011-07-27 11:06, Johan Råde wrote:
>> What is missing here is code that converts X*, Y* and Z* to PyObject*.
>> How do I write that?
> I figured out the answer:
> boost::python::api::object(...).ptr()

No, that did not work.

When I run the following code



     using boost::noncopyable;
     using namespace boost::python;

     class X : noncopyable {};

     PyObject* f()
         return api::object(new X).ptr();

         class_<X, noncopyable>("X");
         def("f", &f);


     import Foo

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?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at