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

Alex Mohr amohr at pixar.com
Thu May 18 01:35:47 CEST 2006


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.

Alex


Ryan Gallagher wrote:
> Just wondering if there where any further thoughts on all this thread.
> 
> http://thread.gmane.org/gmane.comp.python.c++/9664/focus=9703
> 
> I'm sure a few of us at least would like some insight into this.
> 
> Thanks,
> 
> -Ryan
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig



More information about the Cplusplus-sig mailing list