Merge pull request #262 from merlinND/make-tuple-error-message

More informative error message when `py::make_tuple` fails
This commit is contained in:
Wenzel Jakob 2016-07-01 21:48:14 +02:00 committed by GitHub
commit 3b48482f02

View File

@ -838,9 +838,16 @@ template <return_value_policy policy = return_value_policy::automatic_reference,
{ object(detail::type_caster<typename detail::intrinsic_type<Args>::type>::cast( { object(detail::type_caster<typename detail::intrinsic_type<Args>::type>::cast(
std::forward<Args>(args_), policy, nullptr), false)... } std::forward<Args>(args_), policy, nullptr), false)... }
}; };
for (auto &arg_value : args) for (auto &arg_value : args) {
if (!arg_value) if (!arg_value) {
throw cast_error("make_tuple(): unable to convert arguments to Python objects"); #if defined(NDEBUG)
throw cast_error("make_tuple(): unable to convert arguments to Python object (compile in debug mode for details)");
#else
throw cast_error("make_tuple(): unable to convert arguments of types '" +
(std::string) type_id<std::tuple<Args...>>() + "' to Python object");
#endif
}
}
tuple result(size); tuple result(size);
int counter = 0; int counter = 0;
for (auto &arg_value : args) for (auto &arg_value : args)