[Python-checkins] r74414 - in python/branches/tk_and_idle_maintenance/Lib/idlelib: PyShell.py ScriptBinding.py

guilherme.polo python-checkins at python.org
Thu Aug 13 16:47:34 CEST 2009


Author: guilherme.polo
Date: Thu Aug 13 16:47:34 2009
New Revision: 74414
Log:
Cleanup temp files after the IDLE shell ends its execution so tracebacks can be printed without loss of information.
Modified:
 python/branches/tk_and_idle_maintenance/Lib/idlelib/PyShell.py
 python/branches/tk_and_idle_maintenance/Lib/idlelib/ScriptBinding.py
Modified: python/branches/tk_and_idle_maintenance/Lib/idlelib/PyShell.py
==============================================================================
--- python/branches/tk_and_idle_maintenance/Lib/idlelib/PyShell.py	(original)
+++ python/branches/tk_and_idle_maintenance/Lib/idlelib/PyShell.py	Thu Aug 13 16:47:34 2009
@@ -875,6 +875,11 @@
 self.history = self.History(self.text)
 #
 self.pollinterval = 50 # millisec
+ # Cleanup functions to be called when endexecuting is called
+ self._cleanup_funcs = []
+
+ def append_cleanup_func(self, func, *args, **kwargs):
+ self._cleanup_funcs.append((func, args, kwargs))
 
 def get_standard_extension_names(self):
 return idleConf.GetExtensions(shell_only=True)
@@ -949,6 +954,11 @@
 self.canceled = 0
 self.showprompt()
 
+ for func, args, kwargs in self._cleanup_funcs:
+ print func, args, kwargs
+ func(*args, **kwargs)
+ self._cleanup_funcs = []
+
 def close(self):
 "Extend EditorWindow.close()"
 if self.executing:
Modified: python/branches/tk_and_idle_maintenance/Lib/idlelib/ScriptBinding.py
==============================================================================
--- python/branches/tk_and_idle_maintenance/Lib/idlelib/ScriptBinding.py	(original)
+++ python/branches/tk_and_idle_maintenance/Lib/idlelib/ScriptBinding.py	Thu Aug 13 16:47:34 2009
@@ -53,7 +53,7 @@
 self.flist = self.editwin.flist
 self.root = self.editwin.root
 
- def _cleanup_temp(self, filename, is_temp):
+ def _cleanup_temp(self, filename, is_temp=True):
 if is_temp:
 os.unlink(filename)
 
@@ -176,7 +176,8 @@
 # go to __stderr__. With subprocess, they go to the shell.
 # Need to change streams in PyShell.ModifiedInterpreter.
 interp.runcode(code)
- self._cleanup_temp(filename, is_temp)
+ if is_temp:
+ interp.tkconsole.append_cleanup_func(self._cleanup_temp, filename)
 return 'break'
 
 def getfilename(self):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /