[C++-sig] Ping: Howto expose exception classes using boost.python?

David Abrahams dave at boost-consulting.com
Thu May 18 13:34:53 CEST 2006

Alex Mohr <amohr at pixar.com> writes:

> The way I solved it was to actually implement an exception class in 
> python (that derived from RuntimeError) and then call into my wrapped 
> module, passing that class object.
> I store the class object in my C++ code, and then when I want to make an 
> exception, I just invoke the class object's operator(), set the python 
> exception state to that class/instance, and throw_error_already_set().
> It would be lovely if boost python let you create extensions classes 
> that derived from python classes, but I'm not sure what this would entail.

It's been on the TODO list forever, but other priorities have kept us
from addressing it.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list