[Python-checkins] cpython (3.2): Issue #10365: File open dialog now works instead of crashing
terry.reedy
python-checkins at python.org
Sun May 27 02:47:13 CEST 2012
http://hg.python.org/cpython/rev/a2877fbabf95
changeset: 77173:a2877fbabf95
branch: 3.2
parent: 77169:e443cce4f183
user: Terry Jan Reedy <tjreedy at udel.edu>
date: Sat May 26 20:23:45 2012 -0400
summary:
Issue #10365: File open dialog now works instead of crashing
even when parent window is closed. Patch by Roger Serwy.
files:
Lib/idlelib/IOBinding.py | 17 ++++++++++++-----
Lib/idlelib/PyShell.py | 3 ++-
Misc/NEWS | 3 +++
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -156,7 +156,8 @@
self.filename_change_hook()
def open(self, event=None, editFile=None):
- if self.editwin.flist:
+ flist = self.editwin.flist
+ if flist:
if not editFile:
filename = self.askopenfile()
else:
@@ -167,16 +168,22 @@
# 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 not self.filename and self.get_saved() and not interp:
- self.editwin.flist.open(filename, self.loadfile)
+
+ if self.editwin and not self.filename and \
+ self.get_saved() and not interp:
+ flist.open(filename, self.loadfile)
else:
- self.editwin.flist.open(filename)
+ flist.open(filename)
else:
- self.text.focus_set()
+ if self.text:
+ self.text.focus_set()
+
return "break"
#
# Code for use outside IDLE:
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -1435,7 +1435,8 @@
if tkversionwarning:
shell.interp.runcommand(''.join(("print('", tkversionwarning, "')")))
- root.mainloop()
+ while flist.inversedict: # keep IDLE running while files are open.
+ root.mainloop()
root.destroy()
if __name__ == "__main__":
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -67,6 +67,9 @@
Library
-------
+- Issue #10365: File open dialog now works instead of crashing
+ even when parent window is closed. Patch by Roger Serwy.
+
- Issue #14876: Use user-selected font for highlight configuration.
- Issue #14920: Fix the help(urllib.parse) failure on locale C on terminals.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list