Subject: [Boost-bugs] [Boost C++ Libraries] #7080: make_constructor Does Not Initialize base_wrapper
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-07-04 21:00:54
#7080: make_constructor Does Not Initialize base_wrapper
--------------------------------+-------------------------------------------
Reporter: team@⦠| Owner: rwgk
Type: Bugs | Status: new
Milestone: To Be Determined | Component: Python
Version: Boost 1.51.0 | Severity: Problem
Keywords: |
--------------------------------+-------------------------------------------
When binding a shared_ptr to Python, we're using a custom allocator
defined using make_constructor:
{{{
class_< Controller, shared_ptr<Controller>, boost::noncopyable
>("Controller", no_init)
.def("__init__",
boost::python::make_constructor(&Controller::make));
}}}
This works as expected except when classes are derived in Python. In
those cases, get_override does not work, since m_self is NULL. If you use
init<>() in the class_ constructor, instead of the make_constructor line,
it works as expected.
The bug is that make_constructor does not initialize the base_wrapper.
I've tried a fix as follows, and it's now functional -- though I can't say
if this is a good way to solve it.
{{{
+++ make_constructor.hpp
@@ -59,6 +59,7 @@
void* memory = holder::allocate(this->m_self,
offsetof(instance_t, storage), sizeof(holder));
try {
(new (memory) holder(x))->install(this->m_self);
+ python::detail::initialize_wrapper(this->m_self,
get_pointer(x));
}
catch(...) {
holder::deallocate(this->m_self, memory);
}}}
It's also possible to fix this by partially specializing "template
<typename T> struct install_holder;" before boost::python is included.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7080> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC