[C++-sig] Problem with shared_ptr converter in boost 1.60

Carlos Roig roigcarlo at gmail.com
Mon Jan 11 12:09:28 EST 2016


Dear colleges,

I work in a project which makes use of the Boost.python module.

Las week we received feedback from some people that was having problems
after
updating boost from version 1.59 to 1.60.
Specifically the problem appears while trying to use a shared_ptr class.

Until now, we were registering our classes as follows:

class_<Foo, Foo::Pointer, bases<>, boost::noncopyable >("FooClass");

being Foo::Pointer defined as boost::shared_ptr<Foo>

Which automatically created the wrapper for python. Since version 1.60, the
following error appears while trying to access that elements:

>>> for Foo in Mesh.GetFooPointers()
>>>     print(Foo)

TypeError: No to_python (by-value) converter found for C++ type:
boost::shared_ptr<Foo>

We have been "googling" for a while and we found a work-around which
consist in adding:

register_ptr_to_python<Foo::Pointer>();

This would be pretty annoying to do for all our code, as is quite big and
was
designed under the assumption of that boost::shared_ptr<> was automatically
handled by boost.python and there was no need for calling
"register_ptr_to_python", as specified here:
https://wiki.python.org/moin/boost.python/PointersAndSmartPointers

We haven't been able to identify any change that may be affecting this, so
my question is:
Is there any way in which we can restore the old behaviour?
Does this change is inteended?

If it helps, we have perfom tests using clang 3.7 and gcc 5.3, both with
--std=c++11 enabled under linux64 (Kubuntu 15.10, Ubuntu 15.04 and 15.10,
and Arch) using python 3.4.3 with identical results..

Best regards and thank you in advance,

Charlie.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20160111/187bf53c/attachment.html>


More information about the Cplusplus-sig mailing list