[C++-sig] Exception support in CVS version of Boost.Python?

Nicodemus nicodemus at globalite.com.br
Sat Oct 11 00:06:32 CEST 2003


Dan Halbert wrote:

>I am a newcomer to Boost.Python and Pyste. I am very impressed. I
>didn't write a bit of code, and got most of our interface working.
>  
>

Glad to know that some of Pyste is useful. 8)

>One thing I could still use is automatic translation of C++ exceptions
>to Python exceptions. In the C++-SIG mail archives, I see discussion
>of Gottfried G's exception translation automation. I think I see code
>for it in the CVS snapshot of BPL in Boost. But I'm not quite sure how
>this mechanism to be used, as it seemed to be evolving for a while. It
>doesn't seem to be mentioned in the updated documentation.
>  
>

There were some disagreements between Dave and Gottfried about the 
implementation, so its inclusion in the CVS was post-poned until 
Gottfried could do some more work on it, IIRC.

>Could someone supply a simple example of the Pyste exception
>translation construct and a handler function?
>

There is no explicit support for that, mostly because it wasn't really 
asked for. Note that you can include code in the generated files from 
the Pyste files, so that can be used as an workaround.

>And I'll need the latest CVS version of GCC_XML, right?
>

Not for exception translation. You will need the CVS version if your 
virtual classes' member functions declare exception specifiers (is the 
therminology correct?):


    virtual void foo() throw std::runtime_error
    {
        ...
    }

Otherwise, the wrapper classes will end up being generated thus:

    class A_Wrapper(A)
    {
        virtual void foo()
        {
             call_method<void>(self, "foo");
        }
    };

And the code will not compile.

Regards,
Nicodemus.





More information about the Cplusplus-sig mailing list