[C++-sig] Re: Python exceptions
David Abrahams
dave at boost-consulting.com
Sat Jan 8 03:10:32 CET 2005
Jonathan Brandmeyer wrote:
> On Fri, 2005-01-07 at 16:12 -0800, Garrick Meeker wrote:
>> I'm porting some old code to boost. I have a function that returns a
>> PyObject* and if an error occurs it calls
>> PyErr_SetString(PyExc_AttributeError, "...") and returns NULL. No C++
>> exceptions are involved. With boost, however, the NULL is converted to
>> None.
>>
>> How can I generate an AttributeError exception? All I see from the docs
>> is that I could define a new class, call
>> register_exception_translator(), and throw this class. Since I'm not
>> dealing with existing exception classes, is there a simpler, built-in
>> way? Something like:
>>
>> throw boost::python::exception(PyExc_AttributeError, "error string");
>>
>
>
> See: http://www.boost.org/libs/python/doc/v2/errors.htm
http://www.boost.org/libs/python/doc/v2/errors.html
^
?
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list