[C++-sig] How to handle argument error exceptions in boost.python?

Gary Oberbrunner garyo at genarts.com
Sat Jan 11 15:52:42 CET 2014



----- Original Message -----
> From: "Karl Bicker" <karl.bicker at gordiano.net>
> To: "Development of Python/C++ integration" <cplusplus-sig at python.org>
> Sent: Friday, January 10, 2014 8:36:48 AM
> Subject: Re: [C++-sig] How to handle argument error exceptions in boost.python?
> 
> Dear Gary,
> 
> I am not sure if this is what you want, but what about writing a
> wrapper function around EXTrender_effect which takes
> boost::python::objects and then use boost::python::extract to check
> if you can convert the objects you got to what they should be (cf.
> https://wiki.python.org/moin/boost.python/extract)? Does this help?

I suppose it might -- essentially what you're talking about is avoiding boost::python's overloading logic and putting in my own.  Then I could handle arg errors any way I want, because my function would be guaranteed to be called no matter what.  Right?

It seems like a bad solution overall though, because it means most of the coolness of boost::python is gone.  All my functions would just have to take a list of kw args and parse them out themselves, rather than boost::python doing that.  Seems like there must be a better way!  I mean, there is all this logic in the boost::python call framework to build nice error messages about which overloads were tried, but that message never comes out anywhere.

-- 
Gary Oberbrunner


More information about the Cplusplus-sig mailing list