pybind11
pybind11 copied to clipboard
WIP: Guard against Python multiple inheritance divergence
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 withclass_<CppDrvd1Plus2>, in Python inherit fromCppDrvd1Plus2instead ofCppDrvd,CppDrvd2separately.
Suggested changelog entry: