From 3ebe4c47ba098a59417f4afa6e15f256bbbd5261 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 14 Jul 2002 13:04:27 +0000 Subject: [PATCH] Better error reporting [SVN r14448] --- .../boost/python/converter/arg_to_python.hpp | 4 ++-- .../python/converter/arg_to_python_base.hpp | 4 +++- src/converter/callback.cpp | 20 +++++++++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/boost/python/converter/arg_to_python.hpp b/include/boost/python/converter/arg_to_python.hpp index 5f512400..9b6f4b31 100755 --- a/include/boost/python/converter/arg_to_python.hpp +++ b/include/boost/python/converter/arg_to_python.hpp @@ -180,13 +180,13 @@ namespace detail template inline value_arg_to_python::value_arg_to_python(T const& x) - : arg_to_python_base(&x, registered::converters.to_python) + : arg_to_python_base(&x, registered::converters) { } template inline pointer_deep_arg_to_python::pointer_deep_arg_to_python(Ptr x) - : arg_to_python_base(x, registered_pointee::converters.to_python) + : arg_to_python_base(x, registered_pointee::converters) { detail::reject_raw_object_ptr((Ptr)0); } diff --git a/include/boost/python/converter/arg_to_python_base.hpp b/include/boost/python/converter/arg_to_python_base.hpp index bc4dc801..59f68b6d 100755 --- a/include/boost/python/converter/arg_to_python_base.hpp +++ b/include/boost/python/converter/arg_to_python_base.hpp @@ -11,6 +11,8 @@ namespace boost { namespace python { namespace converter { +struct registration; + namespace detail { struct BOOST_PYTHON_DECL arg_to_python_base @@ -18,7 +20,7 @@ namespace detail : handle<> # endif { - arg_to_python_base(void const volatile* source, to_python_function_t); + arg_to_python_base(void const volatile* source, registration const&); # if defined(BOOST_MSVC) && BOOST_MSVC > 1300 && _MSC_FULL_VER <= 13102171 PyObject* get() const { return m_ptr.get(); } PyObject* release() { return m_ptr.release(); } diff --git a/src/converter/callback.cpp b/src/converter/callback.cpp index 3b229f3c..0685a591 100644 --- a/src/converter/callback.cpp +++ b/src/converter/callback.cpp @@ -19,28 +19,32 @@ namespace detail namespace { - inline PyObject* convert_to_python(void const volatile* source, to_python_function_t converter) + inline PyObject* convert_to_python(void const volatile* source, registration const& converters) { - if (converter == 0) + if (converters.to_python == 0) { - PyErr_SetString( + + PyErr_SetObject( PyExc_TypeError - , const_cast("no to_python (by-value) converter found for type")); + , (object("no to_python (by-value) converter found for C++ type: ") + + converters.target_type.name()).ptr() + ); + throw_error_already_set(); } return source == 0 ? python::detail::none() - : converter(const_cast(source)); + : converters.to_python(const_cast(source)); } } arg_to_python_base::arg_to_python_base( - void const volatile* source, to_python_function_t converter) + void const volatile* source, registration const& converters) # if !defined(BOOST_MSVC) || _MSC_FULL_VER != 13102140 - : handle<>(convert_to_python(source, converter)) + : handle<>(convert_to_python(source, converters)) # else - : m_ptr(convert_to_python(source, converter)) + : m_ptr(convert_to_python(source, converters)) # endif { }