Re: Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
On Thu, 02 Aug, Farshid Lashkari wrote: > You cannot use PyRun_SimpleString, since it will automatically print > and clear the error. You will need to use PyRun_String instead. Thanks, that helps a lot! -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Farshid Lashkari
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

Re: Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
On Thu, 02 Aug, Farshid Lashkari wrote: > Also, here is some sample code that will catch system exit exceptions: > > //Call python code > ... > //Check for system exit exception > if(PyErr_Occurred()) { > if(PyErr_ExceptionMatches(PyExc_SystemExit)) { > //handle system exit >

Re: Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
First of all, I'm sorry to followup my own posting, but I can add a few things ... On Thu, 02 Aug, Stefan Bellon wrote: > As in Python itself you can catch SystemExit, I think this should be > the way to go. But how do I catch this exception from within the C > API? I now installed an exception

Re: Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Farshid Lashkari
Stefan Bellon wrote: > Hi all! > > I am embedding Python into a GUI application in a way that the GUI is > scriptable using Python. > > Now I have come to a problem that when the user puts a "sys.exit(0)" > into his script to end the script, not only the script is terminated, > but also the GUI a

Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
Hi all! I am embedding Python into a GUI application in a way that the GUI is scriptable using Python. Now I have come to a problem that when the user puts a "sys.exit(0)" into his script to end the script, not only the script is terminated, but also the GUI application itself. This is not the in