From ecd01da7ac3fe76ad1c171523074d8d068cf5e2a Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 15 Jul 2024 01:33:15 -0700 Subject: [PATCH] `smart_holder_from_unique_ptr`: also accept `return_value_policy::take_ownership` There are no strong reasons for accepting or rejecting `return_value_policy::take_ownership`. Accepting to accommodate existing use cases in the wild. --- include/pybind11/detail/type_caster_base.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index 04e87c24c..3341a1b94 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -635,7 +635,8 @@ handle smart_holder_from_unique_ptr(std::unique_ptr &&src, const std::pair &st) { if (policy != return_value_policy::automatic && policy != return_value_policy::automatic_reference - && policy != return_value_policy::move && policy != return_value_policy::reference + && policy != return_value_policy::take_ownership && policy != return_value_policy::move + && policy != return_value_policy::reference && policy != return_value_policy::reference_internal) { // SMART_HOLDER_WIP: IMPROVABLE: Error message. throw cast_error("Invalid return_value_policy for unique_ptr.");