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)