From 68ca3b6343eb0f616c40353ebcfe5ed5bf7eae10 Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Fri, 1 Jul 2016 20:35:35 +0200 Subject: [PATCH] more informative error message when py::make_tuple fails --- include/pybind11/cast.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 4ba9e275d..4f7bc2d01 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -838,9 +838,16 @@ template ::type>::cast( std::forward(args_), policy, nullptr), false)... } }; - for (auto &arg_value : args) - if (!arg_value) - throw cast_error("make_tuple(): unable to convert arguments to Python objects"); + for (auto &arg_value : args) { + if (!arg_value) { +#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>() + "' to Python object"); +#endif + } + } tuple result(size); int counter = 0; for (auto &arg_value : args)