Modify

Ticket #5803 (closed Bugs: fixed)

Opened 3 years ago

Last modified 3 years ago

MPL assertion does not allow python to override protected virtual methods

Reported by: mathstuf@… Owned by: rwgk
Milestone: To Be Determined Component: Python
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

Change History

comment:1 Changed 3 years ago by rwgk

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

comment:2 follow-up: ↓ 3 Changed 3 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 3 years ago by rwgk

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 3 years ago by rwgk

  • Status changed from new to closed
  • Resolution set to fixed

boost svn trunk rev. 74020: commenting out assertion

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.