[Pyrex] TypeError from Exception

Mark Ellis mark at mpellis.org.uk
Wed Dec 17 12:50:34 CET 2008


Hi All

I'm hoping someone can provide some enlightenment on something. I'm
really a C programmer that knows some python, so while I can understand
what the problem is, I don't know where it's coming from.

We have a pyrex extension wrapping a C library, that contains a simple
class called RAPIError, derived from Exception.

class RAPIError(Exception):
    def __init__(self, retval):
        self.retval = retval

    def __str__(self):
        return str(self.retval)


A few users have reported tracebacks ending with the following.

TypeError: exceptions must be strings, classes, or instances, not
RAPIError

which is the result of

raise RAPIError(retval)

retval being a simple integer.

The problem seems to manifest on Gentoo with pyrex 0.9.4.1; one case
upgraded to 0.9.8.5 which seemed to solve the problem. I'm afraid I
can't tell you the python versions involved, sometimes asking simple
questions like that on user mailing lists gets you nothing :)

However, I have been unable to reproduce this with this version of pyrex
and both python 2.5.2 and 2.4.4.

Can anyone give a a clue as to what is happening here ?

Many thanks
Mark

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20081217/4deb293e/attachment.bin 


More information about the Pyrex mailing list