Boost C++ Libraries: Ticket #5803: MPL assertion does not allow python to override protected virtual methods https://svn.boost.org/trac10/ticket/5803 <p> When wrapping a class with virtual protected methods, the following MPL assertion is hit in boost::python::detail::error::virtual_function_default&lt;&gt; (python/class.hpp:141): </p> <pre class="wiki">assertion&lt;mpl::not_&lt;is_same&lt;Default,Fn&gt; &gt; &gt; </pre><p> The way I've been exposing the protected method so that the Python can override it is: </p> <pre class="wiki">class Base { protected: virtual void foo(); }; class BaseWrap : public Base, public wrapper&lt;Base&gt; { public: void foo(); void base_foo(); }; // ... class_&lt;BaseWrap, boost::noncopyable&gt;("PythonBase") .def("foo", &amp;BaseWrap::foo, &amp;BaseWrap::base_foo); </pre><p> The assertion is *supposed* to be (following the function names) testing that <code></code>&amp;BaseWrap::base_foo<code></code> is a method of the wrapped class (<code></code><a class="missing wiki">BaseWrap</a><code></code>), but it does it in a way that precludes the main overriding function from *also* being from <code></code><a class="missing wiki">BaseWrap</a><code></code> which isn't really correct. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5803 Trac 1.4.3 Ralf W. Grosse-Kunstleve Mon, 22 Aug 2011 23:53:15 GMT <link>https://svn.boost.org/trac10/ticket/5803#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5803#comment:1</guid> <description> <p> We could simply remove the assertion. Does that make sense? </p> </description> <category>Ticket</category> </item> <item> <author>mathstuf@…</author> <pubDate>Tue, 23 Aug 2011 14:18:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5803#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5803#comment:2</guid> <description> <p> Sleeping on it, that would probably make the most sense. </p> <p> In the meantime, is there a workaround that might work? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Tue, 23 Aug 2011 16:17:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5803#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5803#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5803#comment:2" title="Comment 2">mathstuf@…</a>: </p> <blockquote class="citation"> <p> Sleeping on it, that would probably make the most sense. </p> </blockquote> <p> OK, I'll remove the assertion on the trunk (and later on the release branch). </p> <blockquote class="citation"> <p> In the meantime, is there a workaround that might work? </p> </blockquote> <p> If you cannot modify the class.hpp header I don't know. You could ask the Python-C++ SIG. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Tue, 23 Aug 2011 16:26:29 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5803#comment:4 https://svn.boost.org/trac10/ticket/5803#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> boost svn trunk rev. 74020: commenting out assertion </p> Ticket