[Python-checkins] cpython (2.7): Issue 10365: Add and replace comments; condense defaulted attribute access.

terry.reedy python-checkins at python.org
Sun Jun 3 02:25:06 CEST 2012


http://hg.python.org/cpython/rev/5b267381eea0
changeset: 77309:5b267381eea0
branch: 2.7
parent: 77305:50d6592791bd
user: Terry Jan Reedy <tjreedy at udel.edu>
date: Sat Jun 02 20:22:35 2012 -0400
summary:
 Issue 10365: Add and replace comments; condense defaulted attribute access.
Code patch by Roger Serwy.
files:
 Lib/idlelib/IOBinding.py | 29 ++++++++++++---------------
 1 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -197,35 +197,32 @@
 
 def open(self, event=None, editFile=None):
 flist = self.editwin.flist
+ # Save in case parent window is closed (ie, during askopenfile()).
 if flist:
 if not editFile:
 filename = self.askopenfile()
 else:
 filename=editFile
 if filename:
- # If the current window has no filename and hasn't been
- # modified, we replace its contents (no loss). Otherwise
- # we open a new window. But we won't replace the
- # shell window (which has an interp(reter) attribute), which
- # gets set to "not modified" at every new prompt.
- # Also, make sure the current window has not been closed,
- # since it can be closed during the Open File dialog.
- try:
- interp = self.editwin.interp
- except AttributeError:
- interp = None
-
- if self.editwin and not self.filename and \
- self.get_saved() and not interp:
+ # If editFile is valid and already open, flist.open will
+ # shift focus to its existing window.
+ # If the current window exists and is a fresh unnamed,
+ # unmodified editor window (not an interpreter shell),
+ # pass self.loadfile to flist.open so it will load the file
+ # in the current window (if the file is not already open)
+ # instead of a new window.
+ if (self.editwin and
+ not getattr(self.editwin, 'interp', None) and
+ not self.filename and
+ self.get_saved()):
 flist.open(filename, self.loadfile)
 else:
 flist.open(filename)
 else:
 if self.text:
 self.text.focus_set()
+ return "break"
 
- return "break"
- #
 # Code for use outside IDLE:
 if self.get_saved():
 reply = self.maybesave()
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

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