From 72f51e1d89758fe4a6e868eb3f1c0b294c6b8b4c Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 5 May 2022 16:47:29 -0700 Subject: [PATCH] Use PYBIND11_DETAILED_ERROR_MESSAGES in smart_holder_type_casters.h (follow-on to https://github.com/pybind/pybind11/pull/3913) --- include/pybind11/detail/smart_holder_type_casters.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index 67bd237ad..52b37d591 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -722,9 +722,10 @@ struct smart_holder_type_caster : smart_holder_type_caster_load, if (copy_constructor) { valueptr = copy_constructor(src); } else { -#if defined(NDEBUG) +#if !defined(PYBIND11_DETAILED_ERROR_MESSAGES) throw cast_error("return_value_policy = copy, but type is " - "non-copyable! (compile in debug mode for details)"); + "non-copyable! (#define PYBIND11_DETAILED_ERROR_MESSAGES or " + "compile in debug mode for details)"); #else std::string type_name(tinfo->cpptype->name()); detail::clean_type_id(type_name); @@ -741,10 +742,11 @@ struct smart_holder_type_caster : smart_holder_type_caster_load, } else if (copy_constructor) { valueptr = copy_constructor(src); } else { -#if defined(NDEBUG) +#if !defined(PYBIND11_DETAILED_ERROR_MESSAGES) throw cast_error("return_value_policy = move, but type is neither " "movable nor copyable! " - "(compile in debug mode for details)"); + "(#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in " + "debug mode for details)"); #else std::string type_name(tinfo->cpptype->name()); detail::clean_type_id(type_name);