pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

WIP: Guard against Python multiple inheritance divergence

Open rwgk opened this issue 2 years ago • 0 comments

Description

WIP: Follow-on to PR #4762.

Companion branch: https://github.com/google/pywrapcc/pull/30079

Major things to do:

  • Catch all divergence issues in all_type_info_populate() (https://github.com/pybind/pybind11/pull/4762#issuecomment-1799427038).

  • Avoid killing process when divergence is detected:

def NOtest_PPPCCC():
    # terminate called after throwing an instance of 'pybind11::error_already_set'
    # what():  TypeError: bases include diverging derived types:
    #     base=pybind11_tests.python_multiple_inheritance.CppBase,
    #     derived1=pybind11_tests.python_multiple_inheritance.CppDrvd,
    #     derived2=pybind11_tests.python_multiple_inheritance.CppDrvd2
    PPPCCC(11)
  • Document advice for how to handle divergence. Roughly (untested): create a C++ derived type (e.g. class CppDrvd1Plus2 : CppDrvd, CppDrvd2 { ... };), wrap with class_<CppDrvd1Plus2>, in Python inherit from CppDrvd1Plus2 instead of CppDrvd, CppDrvd2 separately.

Suggested changelog entry:


rwgk avatar Nov 08 '23 21:11 rwgk