Extension types as exceptions
Michael P. Reilly
arcege at shore.net
Thu Aug 12 13:59:46 EDT 1999
Daniel Dittmar <daniel.dittmar at sap-ag.de> wrote:
: Should it be possible to use extension types (implemented in C) as
: exceptions?
You do not want to use types as exceptions, you want to use either
strings or exceptions.
: Currently, this works partly, as you can 'raise' and 'except' them.
: It doesn't work in the following code:
: try:
: ... code raising exception
: except EOFException, err:
: pass
: Only strings and python classes seem to be allowed.
And C exception classes created with PyErr_NewException(). This
creates a subclass of "Exception" which can be used to raise and catch
exceptions.
You might want to read:
http://www.python.org/doc/current/api/exceptionHandling.html and
http://starship.python.net/crew/arcege/extwriting/pyext.html (under the
section "Making an exception").
-Arcege
More information about the Python-list
mailing list