Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental: Guard against Python multiple inheritance divergence #4928

Closed

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Nov 8, 2023

Description

WIP: Follow-on to PR #4762.

Companion branch: google/pybind11clif#30079

Major things to do:

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
Copy link
Collaborator Author

rwgk commented Jul 30, 2024

Closing because it is very uncertain when and if work on this will be prioritized. — IMO: Ideally the handling of multiple inheritance in pybind11 is revamped, by porting the Boost.Python approach: https://github.com/boostorg/python/blob/99a5352b5cf790c559a7b976c1ba99520431d9d1/src/object/inheritance.cpp

@rwgk rwgk closed this Jul 30, 2024
@rwgk rwgk changed the title WIP: Guard against Python multiple inheritance divergence Experimental: Guard against Python multiple inheritance divergence Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant