[capi-sig] [Fwd: Re: Exceptions with additional instance variables]

chojrak11 at gmail.com chojrak11 at gmail.com
Mon Dec 22 20:32:02 CET 2008

2008/12/22 Stefan Behnel <python_capi at behnel.de>:

> The quick way to fix your problem might be to write the exception code in
> Cython like thís:
>    class MyException(Exception):
>        def __init__(self, errorcode, message):
>            super(MyException, self).__init__(self, message)
>            self.errorcode = errorcode
> and use that instead. You can also make it an exception class if you like,
> by declaring the Exception class as an external type (requires Py2.5+). In
> this case, Cython can generate a header file for you that declares your
> new extension type.
> http://cython.org/

Hello Stefan,

thanks for the tip, I'll surely look at Cython and how it can help ;-)
Thanks for the pointer and for the example!


More information about the capi-sig mailing list