Fix a long-standing bug in the handling of Python multiple inheritance #30056
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
For full background please see pybind/pybind11#4762.
The core of the added test is this:
Without this PR, the runtime behavior depends on the order in which
PC
orPPCC
are first instantiated, which can be highly surprising and potentially very difficult to debug. See pybind/pybind11#4762 (comment) for a full analysis.However, use cases appear to be surprisingly rare (pybind/pybind11#4762 (comment)). The only known use cases are through PyCLIF.
More-or-less as a side-effect, this PR also:
__init__
unnecessarilty.reinterpret_cast
here: https://github.com/pybind/pybind11/blob/8c7b8dd0ae74b36b7d42f77b0dd4096ebb7f4ab1/include/pybind11/detail/class.h#L193Suggested changelog entry: