Catching SystemExit in C API code when embedding Python?

Farshid Lashkari no at
Thu Aug 2 21:37:11 CEST 2007

Stefan Bellon wrote:
> Thanks for your hints ...
> The interesting part is "Call python code". In my example this is done
> with PyRun_SimpleString which does not return if an exception is not
> handled but raised "out of" the interpreter. So I am unsure of what you
> mean with "Call python code".
> When installing an excepthook (see my other posting), then I can indeed
> catch all exceptions ... except for SystemExit which is the one I'm
> after.

You cannot use PyRun_SimpleString, since it will automatically print and 
clear the error. You will need to use PyRun_String instead.

More information about the Python-list mailing list