[PATCH 2 of 4] cleanup: replace more naked excepts with more specific ones

Brodie Rao brodie at sf.io
Sun May 13 06:20:06 CDT 2012


# HG changeset patch
# User Brodie Rao <brodie at sf.io>
# Date 1336907851 -7200
# Node ID 934247319294cb96997a17f3ad39211795d972b0
# Parent  3ebeec8253ad6e4656cfae774cd5686b8bf6daa6
cleanup: replace more naked excepts with more specific ones

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -488,9 +488,9 @@ class ui(object):
 
     def flush(self):
         try: self.fout.flush()
-        except: pass
+        except (IOError, ValueError): pass
         try: self.ferr.flush()
-        except: pass
+        except (IOError, ValueError): pass
 
     def interactive(self):
         '''is interactive input allowed?
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -762,7 +762,7 @@ def mktempcopy(name, emptyok=False, crea
         ofp.close()
     except:
         try: os.unlink(temp)
-        except: pass
+        except OSError: pass
         raise
     return temp
 
diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -47,7 +47,7 @@ class ProxyHandler (BaseHTTPServer.BaseH
         try: soc.connect(host_port)
         except socket.error, arg:
             try: msg = arg[1]
-            except: msg = arg
+            except (IndexError, TypeError): msg = arg
             self.send_error(404, msg)
             return 0
         return 1


More information about the Mercurial-devel mailing list