From 9c7d2676c95ee54bf5430b69f208a1e46078e6a3 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 28 Jul 2023 13:26:24 -0700 Subject: [PATCH] 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 eb09c6c1b978208ceee40f05bbe75491b6ff8ad6. --- include/pybind11/detail/type_caster_base.h | 27 +++++----------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index 9f4891d01..0fb15a162 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -726,28 +726,13 @@ public: // if we can find an exact match (or, for a simple C++ type, an inherited match); if // so, we can safely reinterpret_cast to the relevant pointer. if (bases.size() > 1) { - type_info *best_base = nullptr; - if (no_cpp_mi) { - for (auto *base : bases) { - if (PyType_IsSubtype(base->type, typeinfo->type)) { - if (best_base == nullptr - || PyType_IsSubtype(base->type, best_base->type)) { - best_base = base; - } - } + for (auto *base : bases) { + if (no_cpp_mi ? PyType_IsSubtype(base->type, typeinfo->type) + : base->type == typeinfo->type) { + this_.load_value( + reinterpret_cast(src.ptr())->get_value_and_holder(base)); + return true; } - } else { - for (auto *base : bases) { - if (base->type == typeinfo->type) { - best_base = base; - break; - } - } - } - if (best_base != nullptr) { - this_.load_value( - reinterpret_cast(src.ptr())->get_value_and_holder(best_base)); - return true; } }