summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/PyShell.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2003-05-24 20:59:15 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2003-05-24 20:59:15 (GMT)
commit67fd0ea46d187ccab90ed574207bc88503bde3ea (patch)
tree9737263bae54a7fbf3e6bb2a77aadbe2793533c3 /Lib/idlelib/PyShell.py
parentebc198faa991ae836547ec1dccea8133b185bd65 (diff)
downloadcpython-67fd0ea46d187ccab90ed574207bc88503bde3ea.zip
cpython-67fd0ea46d187ccab90ed574207bc88503bde3ea.tar.gz
cpython-67fd0ea46d187ccab90ed574207bc88503bde3ea.tar.bz2
1. Stake Freddy.
e.g. further improve subprocess interrupt, exceptions, and termination. 2. Remove the workarounds in PyShell.py and ScriptBinding.py involving interrupting the subprocess prior to killing it, not necessary anymore. 3. Fix a bug introduced at PyShell Rev 1.66: was getting extra shell menu every time the shell window was recreated. M PyShell.py M ScriptBinding.py M rpc.py M run.py
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rw-r--r--Lib/idlelib/PyShell.py45
1 files changed, 22 insertions, 23 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index dc47f07..cb38411 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -296,6 +296,14 @@ class ModifiedUndoDelegator(UndoDelegator):
pass
UndoDelegator.delete(self, index1, index2)
+
+class MyRPCClient(rpc.RPCClient):
+
+ def handle_EOF(self):
+ "Override the base class - just re-raise EOFError"
+ raise EOFError
+
+
class ModifiedInterpreter(InteractiveInterpreter):
def __init__(self, tkconsole):
@@ -329,7 +337,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
for i in range(3):
time.sleep(i)
try:
- self.rpcclt = rpc.RPCClient(addr)
+ self.rpcclt = MyRPCClient(addr)
break
except socket.error, err:
print>>sys.__stderr__,"IDLE socket error: " + err[1]\
@@ -426,9 +434,10 @@ class ModifiedInterpreter(InteractiveInterpreter):
except (EOFError, IOError, KeyboardInterrupt):
# lost connection or subprocess terminated itself, restart
# [the KBI is from rpc.SocketIO.handle_EOF()]
+ if self.tkconsole.closing:
+ return
response = None
self.restart_subprocess()
- self.tkconsole.endexecuting()
if response:
self.tkconsole.resetoutput()
self.active_seq = None
@@ -673,7 +682,9 @@ class PyShell(OutputWindow):
def __init__(self, flist=None):
if use_subprocess:
- self.menu_specs.insert(2, ("shell", "_Shell"))
+ ms = self.menu_specs
+ if ms[2][0] != "shell":
+ ms.insert(2, ("shell", "_Shell"))
self.interp = ModifiedInterpreter(self)
if flist is None:
root = Tk()
@@ -793,15 +804,9 @@ class PyShell(OutputWindow):
parent=self.text)
if response == False:
return "cancel"
- # interrupt the subprocess
- self.canceled = True
- if use_subprocess:
- self.interp.interrupt_subprocess()
- return "cancel"
- else:
- self.closing = True
- # Wait for poll_subprocess() rescheduling to stop
- self.text.after(2 * self.pollinterval, self.close2)
+ self.closing = True
+ # Wait for poll_subprocess() rescheduling to stop
+ self.text.after(2 * self.pollinterval, self.close2)
def close2(self):
return EditorWindow.close(self)
@@ -885,7 +890,10 @@ class PyShell(OutputWindow):
if self.reading:
self.top.quit()
elif (self.executing and self.interp.rpcclt):
- self.interp.interrupt_subprocess()
+ if self.interp.getdebugger():
+ self.interp.restart_subprocess()
+ else:
+ self.interp.interrupt_subprocess()
return "break"
def eof_callback(self, event):
@@ -1021,16 +1029,7 @@ class PyShell(OutputWindow):
self.text.see("restart")
def restart_shell(self, event=None):
- if self.executing:
- self.cancel_callback()
- # Wait for subprocess to interrupt and restart
- # This can be a long time if shell is scrolling on a slow system
- # XXX 14 May 03 KBK This delay (and one in ScriptBinding) could be
- # shorter if we didn't print the KeyboardInterrupt on
- # restarting while user code is running....
- self.text.after(2000, self.interp.restart_subprocess)
- else:
- self.interp.restart_subprocess()
+ self.interp.restart_subprocess()
def showprompt(self):
self.resetoutput()