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

fix: a long-standing bug in the handling of Python multiple inheritance #4762

Merged
merged 35 commits into from
Nov 8, 2023

Commits on Jul 25, 2023

  1. Equivalent of google/clif@5718e4d

    Ralf W. Grosse-Kunstleve committed Jul 25, 2023
    Configuration menu
    Copy the full SHA
    c9a56ac View commit details
    Browse the repository at this point in the history

Commits on Jul 26, 2023

  1. Resolve clang-tidy errors.

    Ralf W. Grosse-Kunstleve committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    bdd938a View commit details
    Browse the repository at this point in the history
  2. Moving test_PPCCInit() first changes the behavior!

    Ralf W. Grosse-Kunstleve committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    61f7529 View commit details
    Browse the repository at this point in the history
  3. Resolve new Clang dev C++11 errors:

    ```
    The CXX compiler identification is Clang 17.0.0
    ```
    
    ```
    pytypes.h:1615:23: error: identifier '_s' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
    ```
    
    ```
    cast.h:1380:26: error: identifier '_a' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
    ```
    Ralf W. Grosse-Kunstleve committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    1fb7dc3 View commit details
    Browse the repository at this point in the history
  4. Resolve gcc 4.8.5 error:

    ```
    pytypes.h:1615:12: error: missing space between '""' and suffix identifier
    ```
    Ralf W. Grosse-Kunstleve committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    b9f3380 View commit details
    Browse the repository at this point in the history
  5. Specifically exclude __clang__

    Ralf W. Grosse-Kunstleve committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    8ea1b8c View commit details
    Browse the repository at this point in the history

Commits on Jul 27, 2023

  1. Snapshot of debugging code (does NOT pass pre-commit checks).

    Ralf W. Grosse-Kunstleve committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    1d4f9ff View commit details
    Browse the repository at this point in the history
  2. Revert "Snapshot of debugging code (does NOT pass pre-commit checks)."

    This reverts commit 1d4f9ff.
    Ralf W. Grosse-Kunstleve committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    775aab5 View commit details
    Browse the repository at this point in the history
  3. [ci skip] Order Dependence Demo

    Ralf W. Grosse-Kunstleve committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    d37b540 View commit details
    Browse the repository at this point in the history
  4. Revert "[ci skip] Order Dependence Demo"

    This reverts commit d37b540.
    Ralf W. Grosse-Kunstleve committed Jul 27, 2023
    Configuration menu
    Copy the full SHA
    7f8b208 View commit details
    Browse the repository at this point in the history

Commits on Jul 28, 2023

  1. One way to deal with the order dependency issue. This is not the best…

    … way, more like a proof of concept.
    Ralf W. Grosse-Kunstleve committed Jul 28, 2023
    Configuration menu
    Copy the full SHA
    eb09c6c View commit details
    Browse the repository at this point in the history
  2. Move test_PC() first again.

    Ralf W. Grosse-Kunstleve committed Jul 28, 2023
    Configuration menu
    Copy the full SHA
    a77c1c6 View commit details
    Browse the repository at this point in the history
  3. Add all_type_info_add_base_most_derived_first(), use in `all_type_i…

    …nfo_populate()`
    Ralf W. Grosse-Kunstleve committed Jul 28, 2023
    Configuration menu
    Copy the full SHA
    eec2d81 View commit details
    Browse the repository at this point in the history
  4. Revert "One way to deal with the order dependency issue. This is not …

    …the best way, more like a proof of concept."
    
    This reverts commit eb09c6c.
    Ralf W. Grosse-Kunstleve committed Jul 28, 2023
    Configuration menu
    Copy the full SHA
    9c7d267 View commit details
    Browse the repository at this point in the history
  5. clang-tidy fixes (automatic)

    Ralf W. Grosse-Kunstleve committed Jul 28, 2023
    Configuration menu
    Copy the full SHA
    7c7d78d View commit details
    Browse the repository at this point in the history
  6. Add is_redundant_value_and_holder() and use to avoid forcing `__ini…

    …t__` overrides when they are not needed.
    Ralf W. Grosse-Kunstleve committed Jul 28, 2023
    Configuration menu
    Copy the full SHA
    d708836 View commit details
    Browse the repository at this point in the history

Commits on Jul 31, 2023

  1. Streamline implementation and avoid unsafe `reinterpret_cast<instance…

    … *>()` introduced with PR pybind#2152
    
    The `reinterpret_cast<instance *>(self)` is unsafe if `__new__` is mocked,
    which was actually found in the wild: the mock returned `None` for `self`.
    This was inconsequential because `inst` is currently cast straight back to
    `PyObject *` to compute `all_type_info()`, which is empty if `self` is not
    a pybind11 `instance`, and then `inst` is never dereferenced. However, the
    unsafe detour through `instance *` is easily avoided and the updated
    implementation is less prone to accidents while debugging or refactoring.
    Ralf W. Grosse-Kunstleve committed Jul 31, 2023
    Configuration menu
    Copy the full SHA
    cf5958d View commit details
    Browse the repository at this point in the history
  2. Fix actual undefined behavior exposed by previous changes.

    It turns out the previous commit message is incorrect, the `inst` pointer is actually dereferenced, in the `value_and_holder` ctor here:
    
    https://github.com/pybind/pybind11/blob/f3e0602802c7840992c97f4960515777cad6a5c7/include/pybind11/detail/type_caster_base.h#L262-L263
    
    ```
    259     // Main constructor for a found value/holder:
    260     value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index)
    261         : inst{i}, index{index}, type{type},
    262           vh{inst->simple_layout ? inst->simple_value_holder
    263                                  : &inst->nonsimple.values_and_holders[vpos]} {}
    ```
    Ralf W. Grosse-Kunstleve committed Jul 31, 2023
    Configuration menu
    Copy the full SHA
    c89561f View commit details
    Browse the repository at this point in the history
  3. Add test_mock_new()

    Ralf W. Grosse-Kunstleve committed Jul 31, 2023
    Configuration menu
    Copy the full SHA
    a2f95e1 View commit details
    Browse the repository at this point in the history
  4. Experiment: specify indirect bases

    Ralf W. Grosse-Kunstleve committed Jul 31, 2023
    Configuration menu
    Copy the full SHA
    4f90d85 View commit details
    Browse the repository at this point in the history

Commits on Aug 4, 2023

  1. Merge branch 'master' into python_multiple_inheritance_test

    Ralf W. Grosse-Kunstleve committed Aug 4, 2023
    Configuration menu
    Copy the full SHA
    0a0debd View commit details
    Browse the repository at this point in the history
  2. Revert "Experiment: specify indirect bases"

    This reverts commit 4f90d85.
    Ralf W. Grosse-Kunstleve committed Aug 4, 2023
    Configuration menu
    Copy the full SHA
    52b7993 View commit details
    Browse the repository at this point in the history

Commits on Aug 15, 2023

  1. Merge branch 'master' into python_multiple_inheritance_test

    Ralf W. Grosse-Kunstleve committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    33805e2 View commit details
    Browse the repository at this point in the history

Commits on Sep 12, 2023

  1. Merge branch 'master' into python_multiple_inheritance_test

    Ralf W. Grosse-Kunstleve committed Sep 12, 2023
    Configuration menu
    Copy the full SHA
    adb5bad View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2023

  1. Merge branch 'master' into python_multiple_inheritance_test

    Ralf W. Grosse-Kunstleve committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    c516151 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2023

  1. Merge branch 'master' into python_multiple_inheritance_test

    Ralf W. Grosse-Kunstleve committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    f3bb31e View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2023

  1. Add all_type_info_check_for_divergence() and some tests.

    Ralf W. Grosse-Kunstleve committed Nov 5, 2023
    Configuration menu
    Copy the full SHA
    0a9599f View commit details
    Browse the repository at this point in the history
  2. Merge branch 'master' into python_multiple_inheritance_test

    Ralf W. Grosse-Kunstleve committed Nov 5, 2023
    Configuration menu
    Copy the full SHA
    86ca4e1 View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2023

  1. Merge branch 'master' into python_multiple_inheritance_test

    Ralf W. Grosse-Kunstleve committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    9ae6cba View commit details
    Browse the repository at this point in the history
  2. Call all_type_info_check_for_divergence() also from `type_caster_ge…

    …neric::load_impl<>`
    Ralf W. Grosse-Kunstleve committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    5f5fd6a View commit details
    Browse the repository at this point in the history
  3. Resolve clang-tidy error:

    ```
    include/pybind11/detail/type_caster_base.h:795:21: error: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty,-warnings-as-errors]
                    if (matching_bases.size() != 0) {
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
                        !matching_bases.empty()
    ```
    Ralf W. Grosse-Kunstleve committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    df27188 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2023

  1. Merge branch 'master' into python_multiple_inheritance_test

    Ralf W. Grosse-Kunstleve committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    52de174 View commit details
    Browse the repository at this point in the history
  2. Revert "Resolve clang-tidy error:"

    This reverts commit df27188.
    Ralf W. Grosse-Kunstleve committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    1b157fc View commit details
    Browse the repository at this point in the history
  3. Revert "Call all_type_info_check_for_divergence() also from `type_c…

    …aster_generic::load_impl<>`"
    
    This reverts commit 5f5fd6a.
    Ralf W. Grosse-Kunstleve committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    7a6c436 View commit details
    Browse the repository at this point in the history
  4. Revert "Add all_type_info_check_for_divergence() and some tests."

    This reverts commit 0a9599f.
    Ralf W. Grosse-Kunstleve committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    6ab605b View commit details
    Browse the repository at this point in the history