Can we in python code, catch exception generated by C++ pythonized function?

Siu-Tong Hui tong at aristotech.com
Fri Jan 12 20:07:58 EST 2001


Thanks for all the responses.

We use SWIG to link from python to C++. Our highest level code is in
python.

What I tried was simply using:

try:
#        call to C++ pythonized function
except:
            print "Error: Abnormal Program Termination"

In the C++ code, I throw an exception. I couldn't catch it in the above
python code.

If I cannot catch exception in python, since we are using python as high
level command shell, we would have to put in exception control codes in
all pythonized C++ functions in order to have bullet-proof exception
protection. If I can catch exception in python, then I only need to do it
once in my highest level command shell in python.

Tong

Mark Hammond wrote:

> In article <3A5A4545.661385AD at aristotech.com>,
>   Siu-Tong Hui <tong at aristotech.com> wrote:
> > I tried and it won't. Anybody have any workaround for that? Any
> pointer
> > is appreciated. Thanks.
>
> I tried and it will.  Anybody have any further details for that?  Any
> pointer to exactly what you mean is appreciated. Thanks.
>
> Sent via Deja.com
> http://www.deja.com/




More information about the Python-list mailing list