[Python-checkins] cpython (3.3): #18151, part 1: Backport idlelilb portion of Andrew Svetlov's 3.4 patch

terry.reedy python-checkins at python.org
Sat Jun 8 06:38:11 CEST 2013


http://hg.python.org/cpython/rev/2fe64ce5da05
changeset:   84055:2fe64ce5da05
branch:      3.3
parent:      84050:a0d8ae880ae6
user:        Terry Jan Reedy <tjreedy at udel.edu>
date:        Sat Jun 08 00:22:45 2013 -0400
summary:
  #18151, part 1: Backport idlelilb portion of Andrew Svetlov's 3.4 patch
changing IOError to OSError (#16715).

files:
  Lib/idlelib/EditorWindow.py  |   2 +-
  Lib/idlelib/GrepDialog.py    |   2 +-
  Lib/idlelib/IOBinding.py     |   4 ++--
  Lib/idlelib/OutputWindow.py  |   2 +-
  Lib/idlelib/PyShell.py       |   8 ++++----
  Lib/idlelib/configHandler.py |  18 +++++++-----------
  Lib/idlelib/rpc.py           |   2 +-
  Lib/idlelib/textView.py      |   2 +-
  8 files changed, 18 insertions(+), 22 deletions(-)


diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -901,7 +901,7 @@
             with open(self.recent_files_path, 'w',
                         encoding='utf_8', errors='replace') as rf_file:
                 rf_file.writelines(rf_list)
-        except IOError as err:
+        except OSError as err:
             if not getattr(self.root, "recentfilelist_error_displayed", False):
                 self.root.recentfilelist_error_displayed = True
                 tkMessageBox.showerror(title='IDLE Error',
diff --git a/Lib/idlelib/GrepDialog.py b/Lib/idlelib/GrepDialog.py
--- a/Lib/idlelib/GrepDialog.py
+++ b/Lib/idlelib/GrepDialog.py
@@ -82,7 +82,7 @@
         for fn in list:
             try:
                 f = open(fn, errors='replace')
-            except IOError as msg:
+            except OSError as msg:
                 print(msg)
                 continue
             lineno = 0
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -213,7 +213,7 @@
             f.seek(0)
             bytes = f.read()
             f.close()
-        except IOError as msg:
+        except OSError as msg:
             tkMessageBox.showerror("I/O Error", str(msg), master=self.text)
             return False
         chars, converted = self._decode(two_lines, bytes)
@@ -378,7 +378,7 @@
             f.flush()
             f.close()
             return True
-        except IOError as msg:
+        except OSError as msg:
             tkMessageBox.showerror("I/O Error", str(msg),
                                    master=self.text)
             return False
diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/OutputWindow.py
--- a/Lib/idlelib/OutputWindow.py
+++ b/Lib/idlelib/OutputWindow.py
@@ -106,7 +106,7 @@
                     f = open(filename, "r")
                     f.close()
                     break
-                except IOError:
+                except OSError:
                     continue
         else:
             return None
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -59,7 +59,7 @@
         try:
             file.write(warnings.formatwarning(message, category, filename,
                                               lineno, line=line))
-        except IOError:
+        except OSError:
             pass  ## file (probably __stderr__) is invalid, warning dropped.
     warnings.showwarning = idle_showwarning
     def idle_formatwarning(message, category, filename, lineno, line=None):
@@ -213,7 +213,7 @@
         try:
             with open(self.breakpointPath, "r") as fp:
                 lines = fp.readlines()
-        except IOError:
+        except OSError:
             lines = []
         try:
             with open(self.breakpointPath, "w") as new_file:
@@ -224,7 +224,7 @@
                 breaks = self.breakpoints
                 if breaks:
                     new_file.write(filename + '=' + str(breaks) + '\n')
-        except IOError as err:
+        except OSError as err:
             if not getattr(self.root, "breakpoint_error_displayed", False):
                 self.root.breakpoint_error_displayed = True
                 tkMessageBox.showerror(title='IDLE Error',
@@ -532,7 +532,7 @@
             return
         try:
             response = clt.pollresponse(self.active_seq, wait=0.05)
-        except (EOFError, IOError, KeyboardInterrupt):
+        except (EOFError, OSError, KeyboardInterrupt):
             # lost connection or subprocess terminated itself, restart
             # [the KBI is from rpc.SocketIO.handle_EOF()]
             if self.tkconsole.closing:
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -142,7 +142,7 @@
             fname = self.file
             try:
                 cfgFile = open(fname, 'w')
-            except IOError:
+            except OSError:
                 os.unlink(fname)
                 cfgFile = open(fname, 'w')
             with cfgFile:
@@ -207,7 +207,7 @@
                         userDir+',\n but the path does not exist.\n')
                 try:
                     sys.stderr.write(warn)
-                except IOError:
+                except OSError:
                     pass
                 userDir = '~'
         if userDir == "~": # still no path to home!
@@ -217,7 +217,7 @@
         if not os.path.exists(userDir):
             try:
                 os.mkdir(userDir)
-            except (OSError, IOError):
+            except OSError:
                 warn = ('\n Warning: unable to create user config directory\n'+
                         userDir+'\n Check path and permissions.\n Exiting!\n\n')
                 sys.stderr.write(warn)
@@ -251,7 +251,7 @@
                                                      raw=raw)))
             try:
                 sys.stderr.write(warning)
-            except IOError:
+            except OSError:
                 pass
         try:
             if self.defaultCfg[configType].has_option(section,option):
@@ -268,13 +268,11 @@
                        (option, section, default))
             try:
                 sys.stderr.write(warning)
-            except IOError:
+            except OSError:
                 pass
         return default
-
     def SetOption(self, configType, section, option, value):
         """In user's config file, set section's option to value.
-
         """
         self.userCfg[configType].SetOption(section, option, value)
 
@@ -380,7 +378,7 @@
                            (element, themeName, theme[element]))
                 try:
                     sys.stderr.write(warning)
-                except IOError:
+                except OSError:
                     pass
             colour=cfgParser.Get(themeName,element,default=theme[element])
             theme[element]=colour
@@ -637,13 +635,11 @@
                                (event, keySetName, keyBindings[event]))
                     try:
                         sys.stderr.write(warning)
-                    except IOError:
+                    except OSError:
                         pass
         return keyBindings
-
     def GetExtraHelpSourceList(self,configSet):
         """Fetch list of extra help sources from a given configSet.
-
         Valid configSets are 'user' or 'default'.  Return a list of tuples of
         the form (menu_item , path_to_help_file , option), or return the empty
         list.  'option' is the sequence number of the help resource.  'option'
diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py
--- a/Lib/idlelib/rpc.py
+++ b/Lib/idlelib/rpc.py
@@ -339,7 +339,7 @@
                 r, w, x = select.select([], [self.sock], [])
                 n = self.sock.send(s[:BUFSIZE])
             except (AttributeError, TypeError):
-                raise IOError("socket no longer exists")
+                raise OSError("socket no longer exists")
             except socket.error:
                 raise
             else:
diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py
--- a/Lib/idlelib/textView.py
+++ b/Lib/idlelib/textView.py
@@ -66,7 +66,7 @@
     try:
         with open(filename, 'r', encoding=encoding) as file:
             contents = file.read()
-    except IOError:
+    except OSError:
         import tkinter.messagebox as tkMessageBox
         tkMessageBox.showerror(title='File Load Error',
                                message='Unable to load file %r .' % filename,

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list