TypeError from Exception

Mark Ellis <[email protected]> Wed, 17 Dec 2008 11:50:34 +0000
Newsgroups gmane.comp.python.pyrex
Message-ID <1229514634.6658.63.camel@mark01>
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

_______________________________________________
Pyrex mailing list
[email protected]
http://lists.copyleft.no/mailman/listinfo/pyrex
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAklI54oACgkQkQq5eu6iQvBnnQCgjryTZjtbV5raVL5eKBnJr8oP
BjAAn3oPjDFWCn4k0EEjP2qQQS+j4SyP
=kIaj
-----END PGP SIGNATURE-----