Modify

Opened 6 years ago

Closed 6 years ago

#5803 closed Bugs (fixed)

MPL assertion does not allow python to override protected virtual methods

Reported by: mathstuf@… Owned by: Ralf W. Grosse-Kunstleve
Milestone: To Be Determined Component: python USE GITHUB
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

When wrapping a class with virtual protected methods, the following MPL assertion is hit in boost::python::detail::error::virtual_function_default<> (python/class.hpp:141):

assertion<mpl::not_<is_same<Default,Fn> > >

The way I've been exposing the protected method so that the Python can override it is:

class Base { protected: virtual void foo(); };
class BaseWrap : public Base, public wrapper<Base> { public: void foo(); void base_foo(); };
// ...
class_<BaseWrap, boost::noncopyable>("PythonBase")
    .def("foo", &BaseWrap::foo, &BaseWrap::base_foo);

The assertion is *supposed* to be (following the function names) testing that &BaseWrap::base_foo is a method of the wrapped class (BaseWrap?), but it does it in a way that precludes the main overriding function from *also* being from BaseWrap? which isn't really correct.

Attachments (0)

Change History (4)

comment:1 Changed 6 years ago by Ralf W. Grosse-Kunstleve

We could simply remove the assertion. Does that make sense?

comment:2 Changed 6 years ago by mathstuf@…

Sleeping on it, that would probably make the most sense.

In the meantime, is there a workaround that might work?

comment:3 in reply to:  2 Changed 6 years ago by Ralf W. Grosse-Kunstleve

Replying to mathstuf@…:

Sleeping on it, that would probably make the most sense.

OK, I'll remove the assertion on the trunk (and later on the release branch).

In the meantime, is there a workaround that might work?

If you cannot modify the class.hpp header I don't know. You could ask the Python-C++ SIG.

comment:4 Changed 6 years ago by Ralf W. Grosse-Kunstleve

Resolution: fixed
Status: newclosed

boost svn trunk rev. 74020: commenting out assertion

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ralf W. Grosse-Kunstleve.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.