diff Lib/idlelib/PyShell.py @ 83069:1e5e497ee33b 2.7

#17614: IDLE no longer raises exception when quickly closing a file.
author Roger Serwy <roger.serwy@gmail.com>
date Tue, 02 Apr 2013 22:37:12 -0500
parents 240c83902fca
children d759b7bc9785 097554712637
line wrap: on
line diff
--- a/Lib/idlelib/PyShell.py	Tue Apr 02 12:15:07 2013 -0400
+++ b/Lib/idlelib/PyShell.py	Tue Apr 02 22:37:12 2013 -0500
@@ -116,12 +116,13 @@
         self.breakpointPath = os.path.join(idleConf.GetUserCfgDir(),
                                            'breakpoints.lst')
         # whenever a file is changed, restore breakpoints
-        if self.io.filename: self.restore_file_breaks()
         def filename_changed_hook(old_hook=self.io.filename_change_hook,
                                   self=self):
             self.restore_file_breaks()
             old_hook()
         self.io.set_filename_change_hook(filename_changed_hook)
+        if self.io.filename:
+            self.restore_file_breaks()
 
     rmenu_specs = [
         ("Cut", "<<cut>>", "rmenu_check_cut"),
@@ -237,6 +238,9 @@
 
     def restore_file_breaks(self):
         self.text.update()   # this enables setting "BREAK" tags to be visible
+        if self.io is None:
+            # can happen if IDLE closes due to the .update() call
+            return
         filename = self.io.filename
         if filename is None:
             return