summaryrefslogtreecommitdiff
path: root/Lib/idlelib/EditorWindow.py
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2011-12-14 14:57:43 -0800
committerNed Deily <nad@acm.org>2011-12-14 14:57:43 -0800
commit40ad04171d7f3773ed29a3ff13a1d58eefab57c2 (patch)
treee062135434d80c078b3b7a8e877117fffcb548f6 /Lib/idlelib/EditorWindow.py
parent27b154ea57dcb4232701504557e7c2cebbd5458e (diff)
downloadcpython-git-40ad04171d7f3773ed29a3ff13a1d58eefab57c2.tar.gz
Issue #4625: If IDLE cannot write to its recent file or breakpoint
files, display a message popup and continue rather than crash. (original patch by Roger Serwy)
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r--Lib/idlelib/EditorWindow.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index 77dcd501e7..f16badb90e 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -796,11 +796,16 @@ class EditorWindow(object):
rf_list = [path for path in rf_list if path not in bad_paths]
ulchars = "1234567890ABCDEFGHIJK"
rf_list = rf_list[0:len(ulchars)]
- rf_file = open(self.recent_files_path, 'w')
try:
- rf_file.writelines(rf_list)
- finally:
- rf_file.close()
+ with open(self.recent_files_path, 'w') as rf_file:
+ rf_file.writelines(rf_list)
+ except IOError as err:
+ if not getattr(self.root, "recentfilelist_error_displayed", False):
+ self.root.recentfilelist_error_displayed = True
+ tkMessageBox.showerror(title='IDLE Error',
+ message='Unable to update Recent Files list:\n%s'
+ % str(err),
+ parent=self.text)
# for each edit window instance, construct the recent files menu
for instance in self.top.instance_dict.keys():
menu = instance.recent_files_menu