[C++-sig] boost.python 2 exception handling

kloeckner at RTNA.DaimlerChrysler.COM kloeckner at RTNA.DaimlerChrysler.COM
Fri Nov 1 01:28:53 CET 2002


hi,

i'm trying to install my own custom exception translator (with Boost.Python from
the Boost 1.29.0 release, gcc-3.2 (GCC) 3.2.1 20021020 (Debian prerelease) and
Python 2.2.2), and my tries are not working out.

I'm doing it like this:

----------------------------------------------------------------
#include <stdexcept>
#include <boost/python.hpp>
#include <Python.h>

using namespace boost::python;
using namespace std;

void TranslateRTE( const runtime_error &ex )
{
  PyErr_SetString( PyExc_RuntimeError, ex.what() );
}

BOOST_PYTHON_MODULE(mapster)
{
  register_exception_translator<runtime_error>( TranslateRTE );
}

----------------------------------------------------------------
and I'm getting a way lengthy response from the compiler...
----------------------------------------------------------------

kloeckner at crunch:~/mapster/cvs/edmap_ng/src$ jam
..found 851 target(s)...
..updating 2 target(s)...
C++ shell/mapster.o
In file included from /home/kloeckner/boost_1_29_0/boost/python.hpp:43,
                 from shell/mapster.cpp:59:
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:184:42: warning: pasting
"operator" and "+" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:185:42: warning: pasting
"operator" and "-" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:186:42: warning: pasting
"operator" and "*" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:187:42: warning: pasting
"operator" and "/" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:188:42: warning: pasting
"operator" and "%" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:189:49: warning: pasting
"operator" and "<<" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:190:49: warning: pasting
"operator" and ">>" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:191:42: warning: pasting
"operator" and "&" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:192:42: warning: pasting
"operator" and "^" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:193:40: warning: pasting
"operator" and "|" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:194:39: warning: pasting
"operator" and ">" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:195:40: warning: pasting
"operator" and ">=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:196:39: warning: pasting
"operator" and "<" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:197:40: warning: pasting
"operator" and "<=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:198:40: warning: pasting
"operator" and "==" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:199:40: warning: pasting
"operator" and "!=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:271:38: warning: pasting
"operator" and "+=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:272:38: warning: pasting
"operator" and "-=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:273:38: warning: pasting
"operator" and "*=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:274:38: warning: pasting
"operator" and "/=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:275:38: warning: pasting
"operator" and "%=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:276:42: warning: pasting
"operator" and "<<=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:277:42: warning: pasting
"operator" and ">>=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:278:38: warning: pasting
"operator" and "&=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:279:38: warning: pasting
"operator" and "^=" does not give a valid preprocessing token
/home/kloeckner/boost_1_29_0/boost/python/operators.hpp:280:37: warning: pasting
"operator" and "|=" does not give a valid preprocessing token
In file included from shell/mapster.cpp:59:
/home/kloeckner/boost_1_29_0/boost/python.hpp:62:8: warning: extra tokens at end
of #endif directive
/home/kloeckner/boost_1_29_0/boost/bind.hpp: In member function `R
   boost::_bi::list3<A1, A2, A3>::operator()(boost::_bi::type<R>, F, A&) const
   [with R = bool, F =
   boost::python::detail::translate_exception<std::runtime_error, void ()(const
   std::runtime_error&)>, A = boost::_bi::list2<const
   boost::python::detail::exception_handler&, const boost::function0<void,
   boost::empty_function_policy, boost::empty_function_mixin,
   std::allocator<boost::function_base> >&>, A1 = boost::arg<1>, A2 =
   boost::arg<2>, A3 = boost::_bi::value<void (*)(const
   std::runtime_error&)>]':
/home/kloeckner/boost_1_29_0/boost/function/function_template.hpp:44:  
instantiated from `boost::_bi::result_traits<R, F>::type boost::_bi::bind_t<R,
F, L>::operator()(A1&, A2&) [with A1 = const
boost::python::detail::exception_handler, A2 = const boost::function0<void,
boost::empty_function_policy, boost::empty_function_mixin,
std::allocator<boost::function_base> >, R = bool, F =
boost::python::detail::translate_exception<std::runtime_error, void ()(const
std::runtime_error&)>, L = boost::_bi::list3<boost::arg<1>, boost::arg<2>,
boost::_bi::value<void (*)(const std::runtime_error&)> >]'
/home/kloeckner/boost_1_29_0/boost/function/function_template.hpp:110:  
instantiated from `static R
boost::detail::function::function_obj_invoker2<FunctionObj, R, T0,
T1>::invoke(boost::detail::function::any_pointer, T0, T1) [with FunctionObj =
boost::_bi::bind_t<bool,
boost::python::detail::translate_exception<std::runtime_error, void ()(const
std::runtime_error&)>, boost::_bi::list3<boost::arg<1>, boost::arg<2>,
boost::_bi::value<void (*)(const std::runtime_error&)> > >, R = bool, T0 = const
boost::python::detail::exception_handler&, T1 = const boost::function0<void,
boost::empty_function_policy, boost::empty_function_mixin,
std::allocator<boost::function_base> >&]'
/home/kloeckner/boost_1_29_0/boost/function/function_template.hpp:505:  
instantiated from `void boost::function2<R, T0, T1, Policy, Mixin,
Allocator>::assign_to(FunctionObj, boost::detail::function::function_obj_tag)
[with FunctionObj = boost::_bi::bind_t<bool,
boost::python::detail::translate_exception<std::runtime_error, void ()(const
std::runtime_error&)>, boost::_bi::list3<boost::arg<1>, boost::arg<2>,
boost::_bi::value<void (*)(const std::runtime_error&)> > >, R = bool, T0 = const
boost::python::detail::exception_handler&, T1 = const boost::function0<void,
boost::empty_function_policy, boost::empty_function_mixin,
std::allocator<boost::function_base> >&, Policy = boost::empty_function_policy,
Mixin = boost::empty_function_mixin, Allocator =
std::allocator<boost::function_base>]'
/home/kloeckner/boost_1_29_0/boost/python/exception_translator.hpp:456:  
instantiated from `void boost::function2<R, T0, T1, Policy, Mixin,
Allocator>::assign_to(Functor) [with Functor = boost::_bi::bind_t<bool,
boost::python::detail::translate_exception<std::runtime_error, void ()(const
std::runtime_error&)>, boost::_bi::list3<boost::arg<1>, boost::arg<2>,
boost::_bi::value<void (*)(const std::runtime_error&)> > >, R = bool, T0 = const
boost::python::detail::exception_handler&, T1 = const boost::function0<void,
boost::empty_function_policy, boost::empty_function_mixin,
std::allocator<boost::function_base> >&, Policy = boost::empty_function_policy,
Mixin = boost::empty_function_mixin, Allocator =
std::allocator<boost::function_base>]'
/home/kloeckner/boost_1_29_0/boost/python/exception_translator.hpp:296:  
instantiated from `boost::function2<R, T0, T1, Policy, Mixin,
Allocator>::function2(Functor) [with Functor = boost::_bi::bind_t<bool,
boost::python::detail::translate_exception<std::runtime_error, void ()(const
std::runtime_error&)>, boost::_bi::list3<boost::arg<1>, boost::arg<2>,
boost::_bi::value<void (*)(const std::runtime_error&)> > >, R = bool, T0 = const
boost::python::detail::exception_handler&, T1 = const boost::function0<void,
boost::empty_function_policy, boost::empty_function_mixin,
std::allocator<boost::function_base> >&, Policy = boost::empty_function_policy,
Mixin = boost::empty_function_mixin, Allocator =
std::allocator<boost::function_base>]'
/home/kloeckner/boost_1_29_0/boost/python/exception_translator.hpp:18:  
instantiated from `void boost::python::register_exception_translator(const
Translate&, boost::type<Target>*) [with ExceptionType = std::runtime_error,
Translate = void ()(const std::runtime_error&)]'
shell/mapster.cpp:72:   instantiated from here
/home/kloeckner/boost_1_29_0/boost/bind.hpp:285: no match for call to `(
   boost::python::detail::translate_exception<std::runtime_error, void ()(const
   std::runtime_error&)>) (const boost::python::detail::exception_handler&,
   const boost::function0<void, boost::empty_function_policy,
   boost::empty_function_mixin, std::allocator<boost::function_base> >&, void
   (* const&)(const std::runtime_error&))'
/home/kloeckner/boost_1_29_0/boost/python/detail/translate_exception.hpp:30:
candidates
   are: bool boost::python::detail::translate_exception<ExceptionType,
   Translate>::operator()(const boost::python::detail::exception_handler&,
   const boost::function0<void, boost::empty_function_policy,
   boost::empty_function_mixin, std::allocator<boost::function_base> >&,
   boost::call_traits<Translate>::param_type) const [with ExceptionType =
   std::runtime_error, Translate = void ()(const std::runtime_error&)]

g++-3.2  -c -o shell/mapster.o  -g -pthread -fPIC -O  -D_GNU_SOURCE -DOTL_ODBC
-DOTL_ODBC_UNIX -DOTL_STL  -Ishell -I. -I/usr/include/python2.2 -I.
-I/home/kloeckner/boost_1_29_0  shell/mapster.cpp

..failed C++ shell/mapster.o ...
..skipped mapster.so for lack of <shell>mapster.o...
..failed updating 1 target(s)...
..skipped 1 target(s)...

----------------------------------------------------------------
Any help is appreciated.

Thanks
  --
Andreas





More information about the Cplusplus-sig mailing list