diff -r e8d89503f061 Lib/idlelib/IOBinding.py --- a/Lib/idlelib/IOBinding.py Sat May 26 20:44:45 2012 -0400 +++ b/Lib/idlelib/IOBinding.py Sun May 27 14:07:40 2012 -0500 @@ -156,7 +156,7 @@ self.filename_change_hook() def open(self, event=None, editFile=None): - flist = self.editwin.flist + flist = self.editwin.flist # Save flist in case parent window closes. if flist: if not editFile: filename = self.askopenfile() @@ -164,23 +164,24 @@ 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: + # modified, we replace its contents (no loss). Otherwise + # we open a new window. A shell window (which has an + # interp(reter) attribute, no filename, and gets set to + # "not modified" at every new prompt) will never have + # its contents replaced. + # Also, if the current window was closed during askopenfile, + # then open in a new window. + if (self.editwin and + not getattr(self.editwin, 'interp', None) and + not self.filename and + self.get_saved()): + # Open into the blank, unmodified Editor Window flist.open(filename, self.loadfile) else: + # Open in a new Editor Window flist.open(filename) else: + # No file to open if self.text: self.text.focus_set()