Hi there, I have verified the VIDLE fork last week expecting to find many differences between it and IDLE. Most files differ but it turned out that most of these differences are equivalent (many of the changes were merged already), except for two of them. One of these changes is related to py2app, so I can't verify it. The second is about using the subprocess module to spawn the subprocess, so it is easier to terminate it properly under Windows (the original code was a bit different since it was done before Python 2.6). I'm not a heavy Windows so I can't tell how much this helps, my guess is that it would help with http://bugs.python.org/issue2708.
Do anyone believe these changes could help IDLE ? Index: Lib/idlelib/PyShell.py =================================================================== --- Lib/idlelib/PyShell.py (revision 74191) +++ Lib/idlelib/PyShell.py (working copy) @@ -11,6 +11,7 @@ import threading import traceback import types +import subprocess import macosxSupport import linecache @@ -40,11 +41,6 @@ HOST = '127.0.0.1' # python execution server on localhost loopback PORT = 0 # someday pass in host, port for remote debug capability -try: - from signal import SIGTERM -except ImportError: - SIGTERM = 15 - # Override warnings module to write to warning_stream. Initialize to send IDLE # internal warnings to the console. ScriptBinding.check_syntax() will # temporarily redirect the stream to the shell window to display warnings when @@ -347,13 +343,13 @@ self.port = PORT rpcclt = None - rpcpid = None + rpcproc = None def spawn_subprocess(self): - if self.subprocess_arglist == None: + if self.subprocess_arglist is None: self.subprocess_arglist = self.build_subprocess_arglist() args = self.subprocess_arglist - self.rpcpid = os.spawnv(os.P_NOWAIT, sys.executable, args) + self.rpcproc = subprocess.Popen([sys.executable] + args[1:]) def build_subprocess_arglist(self): assert (self.port!=0), ( @@ -433,7 +429,7 @@ pass # Kill subprocess, spawn a new one, accept connection. self.rpcclt.close() - self.unix_terminate() + self.terminate_subprocess() console = self.tkconsole was_executing = console.executing console.executing = False @@ -474,23 +470,14 @@ self.rpcclt.close() except AttributeError: # no socket pass - self.unix_terminate() + self.terminate_subprocess() self.tkconsole.executing = False self.rpcclt = None - def unix_terminate(self): - "UNIX: make sure subprocess is terminated and collect status" - if hasattr(os, 'kill'): - try: - os.kill(self.rpcpid, SIGTERM) - except OSError: - # process already terminated: - return - else: - try: - os.waitpid(self.rpcpid, 0) - except OSError: - return + def terminate_subprocess(self): + "Make sure subprocess is terminated and collect status." + self.rpcproc.kill() + self.rpcproc.wait() def transfer_path(self): self.runcommand("""if 1: @@ -1312,6 +1299,8 @@ def main(): global flist, root, use_subprocess + macosxSupport.preprocessArguments() + use_subprocess = True enable_shell = True enable_edit = False Index: Lib/idlelib/macosxSupport.py =================================================================== --- Lib/idlelib/macosxSupport.py (revision 74191) +++ Lib/idlelib/macosxSupport.py (working copy) @@ -9,7 +9,7 @@ """ Returns True if Python is running from within an app on OSX. If so, assume that Python was built with Aqua Tcl/Tk rather than - X11 Tck/Tk. + X11 Tcl/Tk. """ return (sys.platform == 'darwin' and '.app' in sys.executable) @@ -121,6 +121,13 @@ menu.add_command(label=label, underline=underline, command=command, accelerator=accelerator) +def preprocessArguments(): + # Deal with spurious argument passed by Finder, so "argv emulation" is + # not required for app bundle + argv = sys.argv + if runningAsOSXApp() and len(argv) > 1 and argv[1].startswith("-psn"): + del sys.argv[1] + def setupApp(root, flist): """ Perform setup for the OSX application bundle. -- -- Guilherme H. Polo Goncalves _______________________________________________ IDLE-dev mailing list IDLE-dev@python.org http://mail.python.org/mailman/listinfo/idle-dev