This discussion started on pythonmac-SIG, but someone suggested that it isn't really a MacPython-specific issue (even though the implementation will be different for MacPython from unix-Python). Any opinions? Begin forwarded message:
From: Martin Miller <mmiller@adobe.com> Date: Wed Jan 30, 2002 08:14:13 PM Europe/Amsterdam To: pythonmac-sig@python.org Subject: Re: [Pythonmac-SIG] sys.exit() functionality
On Wed, 30 Jan 2002 15:29:21 +0100, Jack Jansen wrote:
On Tuesday, January 29, 2002, at 08:54 , Jon Bradley wrote:
hey all,
In embedded Python - why does sys.exit() quit out of the application that's embedding the interpreter? Is there any way to trap or disregard this?
If a user creates an application with Python and runs it through the embedded interpreter, calling quit or exit on the Python application itself is more than ok, but allowing it to force out of the parent application isn't.
Sounds reasonable. How about a routine PyMac_SetExitFunc() that you could call to set your own exit function, (similar to PyMac_SetConsoleHandler())? MacPython would then do all it's normal cleanup, but at the very end call your routine in stead of exit().
With an approach like the above, wouldn't it be better to have a platform-independent way of defining a custom exit function, rather than calling a Mac-only system function -- or is this whole thing only an issue with MacPython embedding?
Martin
_______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
-- - Jack Jansen <Jack.Jansen@oratrix.com> http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman -
Jack Jansen <Jack.Jansen@oratrix.nl> writes:
This discussion started on pythonmac-SIG, but someone suggested that it isn't really a MacPython-specific issue (even though the implementation will be different for MacPython from unix-Python).
Any opinions?
I think allowing to replace Py_Exit is the right way to go. Make it a function pointer, initialized to _Py_Exit, and let the embedding context change its value (through a setter, or through direct assignment). Double-check that all callers of Py_Exit behave well when it actually does return (which currently is not the case), and don't forget to bump the API version. Regards, Martin
participants (2)
-
Jack Jansen
-
martin@v.loewis.de