From 6fb8b5157dc80867c237cc8b32a6d545f48f824b Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 19 Jul 2024 09:00:03 -0700 Subject: [PATCH] Add back original `copyable_holder_caster` `check_holder_compat()` in the `std::shared_ptr` specialization and remove `pytest.skip("BAKEIN_EXPECTED: ...)` in test_smart_ptr.py --- include/pybind11/cast.h | 5 +++++ tests/test_smart_ptr.py | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 3a3a0c964..541b71d25 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -919,6 +919,11 @@ public: protected: friend class type_caster_generic; + void check_holder_compat() { + if (typeinfo->default_holder) { + throw cast_error("Unable to load a custom holder type from a default-holder instance"); + } + } void load_value(value_and_holder &&v_h) { if (typeinfo->holder_enum_v == detail::holder_enum_t::smart_holder) { diff --git a/tests/test_smart_ptr.py b/tests/test_smart_ptr.py index 0d1961999..bf0ae4aeb 100644 --- a/tests/test_smart_ptr.py +++ b/tests/test_smart_ptr.py @@ -298,7 +298,6 @@ def test_move_only_holder_with_addressof_operator(): def test_smart_ptr_from_default(): - pytest.skip("BAKEIN_EXPECTED: Failed: DID NOT RAISE ") instance = m.HeldByDefaultHolder() with pytest.raises(RuntimeError) as excinfo: m.HeldByDefaultHolder.load_shared_ptr(instance)