[Pythonmac-SIG] Embedding in code resource

Jack Jansen jack@oratrix.nl
Wed, 21 Nov 2001 17:15:12 +0100


> I'm trying to embed MacPython (Classic) in a plug-in code resource for
> another application.  Basically, I need to be able to start up an
> interactive interpreter, let the user play around in it, then exit clea=
nly
> to the calling application.  I had little difficulty getting the first =
part
> of that working, by linking against PythonCore and calling
> PyMac_Initialize, etc.  However, there's a big problem when trying to
> return - all ways of exiting the interpreter seem to eventually involve=
 a C
> exit() call, which is a complete disaster from a code resource.  Does
> anyone know of a way to get the interpreter to exit cleanly to its call=
er?

what you want to do is probably
  PyMac_Initialize();
  PyRun_AnyFile(stdin_for_python, "<stdin>");
I think this should never call exit(), but always return.

Depending on how your code resource is linked against PythonCore you may =
be =

able to do simply "stdin" for stdin_for_python, but it could also be more=
 work =

to get at that.

--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++=

Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig =
++++
www.cwi.nl/~jack        | see http://www.xs4all.nl/~tank/spg-l/sigaction.=
htm =