Embedded Python and sys.exit()
Mitchell Morris
mmorris at mindspring.com
Fri Mar 31 00:30:27 EST 2000
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 this
weekend.
dang-that-interpreter-ly y'rs
+Mitchell
More information about the Python-list
mailing list