[C++-sig] Catching a user defined C++ exception in python.

Jeff Holle jeff.holle at verizon.net
Fri May 21 09:53:27 CEST 2004

I am using gcc v3.3.2 and boost v1.31.0 on a Mandrake 10 linux system.

I've a python extention module developed with boost.python via pyste.
It is a parser and I've recently added an exception object called 
IllegalSyntax that is thrown when unrecognized syntax is encountered.

Presently, my python script that drives it teminates with the following 
message when this exception is thrown:
    RuntimeError: 13IllegalSyntax

I've attempted to place this "catch" clause in my script, but it doesn't 
catch anything:
    except IllegalSyntax, x:
      print "got IllegalSyntax exception"

When I try changing the exception type to "13IllegalSyntax", I get a 
python error indicating that this is illegal syntax.

I haven't done anything other than wrap my IllegalSyntax object via 
Pyste using the following pyste script:
    a = Class("IllegalSyntax","exception.h")

Can anybody tell me what else I needed to caught this exception in python?

More information about the Cplusplus-sig mailing list