Boost C++ Libraries: Ticket #7080: make_constructor Does Not Initialize base_wrapper https://svn.boost.org/trac10/ticket/7080 <p> When binding a shared_ptr to Python, we're using a custom allocator defined using make_constructor: </p> <pre class="wiki">class_&lt; Controller, shared_ptr&lt;Controller&gt;, boost::noncopyable &gt;("Controller", no_init) .def("__init__", boost::python::make_constructor(&amp;Controller::make)); </pre><p> 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&lt;&gt;() in the class_ constructor, instead of the make_constructor line, it works as expected. </p> <p> 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. </p> <pre class="wiki">+++ make_constructor.hpp @@ -59,6 +59,7 @@ void* memory = holder::allocate(this-&gt;m_self, offsetof(instance_t, storage), sizeof(holder)); try { (new (memory) holder(x))-&gt;install(this-&gt;m_self); + python::detail::initialize_wrapper(this-&gt;m_self, get_pointer(x)); } catch(...) { holder::deallocate(this-&gt;m_self, memory); </pre><p> It's also possible to fix this by partially specializing "template &lt;typename T&gt; struct install_holder;" before boost::python is included. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7080 Trac 1.4.3 dave@… Mon, 09 Jul 2012 16:31:18 GMT <link>https://svn.boost.org/trac10/ticket/7080#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7080#comment:1</guid> <description> <p> Dave, could you comment? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Mon, 09 Jul 2012 16:35:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7080#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7080#comment:2</guid> <description> <p> (Sorry I misunderstood the trac interface; that was rwgk trying to ask Dave to comment.) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Dave Abrahams</dc:creator> <pubDate>Mon, 09 Jul 2012 17:06:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7080#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7080#comment:3</guid> <description> <p> Sorry, I don't have much to add merely on the basis of inspecting the patch. If it passes the usual criteria (comes with a test case that it fixes, doesn't break any other tests), I'd be generally biased towards accepting it. </p> </description> <category>Ticket</category> </item> <item> <author>jonatan@…</author> <pubDate>Fri, 01 Mar 2013 15:41:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7080#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7080#comment:4</guid> <description> <p> Any progress on this? </p> </description> <category>Ticket</category> </item> </channel> </rss>