diff options
author | Ned Deily <nad@acm.org> | 2011-12-14 22:58:24 (GMT) |
---|---|---|
committer | Ned Deily <nad@acm.org> | 2011-12-14 22:58:24 (GMT) |
commit | f505b7425c1e46e847dfc1e4528bc178af06b085 (patch) | |
tree | e06db8ae4fab9080ea6b64501e65a7ae5e208686 /Lib/idlelib/PyShell.py | |
parent | 83ef2549de1f1f1eddf43934cacd6c57295e6681 (diff) | |
download | cpython-f505b7425c1e46e847dfc1e4528bc178af06b085.zip cpython-f505b7425c1e46e847dfc1e4528bc178af06b085.tar.gz cpython-f505b7425c1e46e847dfc1e4528bc178af06b085.tar.bz2 |
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/PyShell.py')
-rw-r--r-- | Lib/idlelib/PyShell.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index 33deb45..e7c71b7 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -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 |