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)
This commit is contained in:
Ned Deily 2011-12-14 14:58:24 -08:00
parent 83ef2549de
commit f505b7425c
2 changed files with 26 additions and 13 deletions

View file

@ -206,14 +206,22 @@ class PyShellEditorWindow(EditorWindow):
lines = fp.readlines()
except IOError:
lines = []
with open(self.breakpointPath, "w") as new_file:
for line in lines:
if not line.startswith(filename + '='):
new_file.write(line)
self.update_breakpoints()
breaks = self.breakpoints
if breaks:
new_file.write(filename + '=' + str(breaks) + '\n')
try:
with open(self.breakpointPath, "w") as new_file:
for line in lines:
if not line.startswith(filename + '='):
new_file.write(line)
self.update_breakpoints()
breaks = self.breakpoints
if breaks:
new_file.write(filename + '=' + str(breaks) + '\n')
except IOError as err:
if not getattr(self.root, "breakpoint_error_displayed", False):
self.root.breakpoint_error_displayed = True
tkMessageBox.showerror(title='IDLE Error',
message='Unable to update breakpoint list:\n%s'
% str(err),
parent=self.text)
def restore_file_breaks(self):
self.text.update() # this enables setting "BREAK" tags to be visible