Embedded Python and sys.exit()
cpr at emsoftware.com
Fri Mar 31 15:29:29 CEST 2000
Yes, or maybe you could define your own exit() routine to replace the
standard library version, which would inspect a global in_python and do
nothing if it's being called when you know you're in the Python interpreter.
Just a thought.
/ Chris Ryland, President / Em Software, Inc. / www.emsoftware.com
"Mitchell Morris" <mmorris at mindspring.com> wrote in message
news:8F07D4593beable at 18.104.22.168...
> angelow at tttech.com (Harald Angelow) wrote in
> <954342057.403349 at newsmaster-04.atnet.at>:
> >I have embedded Python in a Win MFC program and execute script files
> >and simple strings.
> >(Py_RunFile, PyRun_String)
> >If the python script raises SystemExit or calls sys.exit() the whole
> >process is shut down.
> >How can I manage that only the Python Interpreter stops and returns from
> >the function call of
> >Py_RunFile or PyRun_String? Does Python know, that it is embedded?
> >thanks Harald
> The short answer is you have to avoid running PyErr_Print().
> The long answer is you'll probably wind up cutting-n-pasting large chunks
> of the source to PyErr_PrintEx() into your code to avoid the exit() call
> contained therein.
> Somewhere around here I've got a paper I wrote about doing exactly this
> with Python, Perl and Tcl. I'll try to dig it up and post it in before
> dang-that-interpreter-ly y'rs
More information about the Python-list