Mercurial > hg
changeset 14004:97ed99d1f419
eliminate various naked except clauses
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Sat, 23 Apr 2011 00:51:25 +0300 |
parents | ba734ff5cadd |
children | bb391e0515ba |
files | mercurial/bookmarks.py mercurial/bundlerepo.py mercurial/changelog.py mercurial/cmdutil.py mercurial/context.py mercurial/dispatch.py mercurial/hg.py mercurial/localrepo.py mercurial/posix.py mercurial/sshrepo.py mercurial/util.py mercurial/windows.py |
diffstat | 12 files changed, 18 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/bookmarks.py Sat Apr 23 00:51:25 2011 +0300 @@ -29,7 +29,7 @@ sha, refspec = line.strip().split(' ', 1) refspec = encoding.tolocal(refspec) bookmarks[refspec] = repo.changelog.lookup(sha) - except: + except IOError: pass return bookmarks
--- a/mercurial/bundlerepo.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/bundlerepo.py Sat Apr 23 00:51:25 2011 +0300 @@ -294,7 +294,7 @@ if not incoming: try: os.unlink(bundlename) - except: + except OSError: pass return other, None, None, None
--- a/mercurial/changelog.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/changelog.py Sat Apr 23 00:51:25 2011 +0300 @@ -185,7 +185,7 @@ try: # various tools did silly things with the time zone field. timezone = int(extra_data[0]) - except: + except ValueError: timezone = 0 extra = {} else:
--- a/mercurial/cmdutil.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/cmdutil.py Sat Apr 23 00:51:25 2011 +0300 @@ -293,7 +293,7 @@ good = True try: audit_path(abs) - except: + except (OSError, util.Abort): good = False rel = m.rel(abs) exact = m.exact(abs)
--- a/mercurial/context.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/context.py Sat Apr 23 00:51:25 2011 +0300 @@ -805,7 +805,7 @@ p = self._repo.wjoin(f) try: st = os.lstat(p) - except: + except OSError: ui.warn(_("%s does not exist!\n") % join(f)) rejected.append(f) continue
--- a/mercurial/dispatch.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/dispatch.py Sat Apr 23 00:51:25 2011 +0300 @@ -133,7 +133,7 @@ elif hasattr(inst, "reason"): try: # usually it is in the form (errno, strerror) reason = inst.reason.args[1] - except: # it might be anything, for example a string + except AttributeError: # it might be anything, for example a string reason = inst.reason ui.warn(_("abort: error: %s\n") % reason) elif hasattr(inst, "args") and inst.args[0] == errno.EPIPE:
--- a/mercurial/hg.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/hg.py Sat Apr 23 00:51:25 2011 +0300 @@ -363,7 +363,7 @@ try: m = dest_repo.lookup(n) dest_repo._bookmarks[k] = m - except: + except error.RepoLookupError: pass if rb: bookmarks.write(dest_repo)
--- a/mercurial/localrepo.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/localrepo.py Sat Apr 23 00:51:25 2011 +0300 @@ -549,7 +549,7 @@ try: if len(key) == 20: key = hex(key) - except: + except TypeError: pass raise error.RepoLookupError(_("unknown revision '%s'") % key)
--- a/mercurial/posix.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/posix.py Sat Apr 23 00:51:25 2011 +0300 @@ -59,7 +59,7 @@ os.unlink(f) try: os.symlink(data, f) - except: + except OSError: # failed to make a link, rewrite file fp = open(f, "w") fp.write(data)
--- a/mercurial/sshrepo.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/sshrepo.py Sat Apr 23 00:51:25 2011 +0300 @@ -167,7 +167,7 @@ self.readerr() try: l = int(l) - except: + except ValueError: self._abort(error.ResponseError(_("unexpected response:"), l)) return self.pipei.read(l) @@ -208,7 +208,7 @@ return 1 try: return int(r) - except: + except ValueError: self._abort(error.ResponseError(_("unexpected response:"), r)) instance = sshrepository
--- a/mercurial/util.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/util.py Sat Apr 23 00:51:25 2011 +0300 @@ -206,12 +206,12 @@ try: if inname: os.unlink(inname) - except: + except OSError: pass try: if outname: os.unlink(outname) - except: + except OSError: pass filtertable = { @@ -407,7 +407,7 @@ if os.path.islink(src): try: os.unlink(dest) - except: + except OSError: pass os.symlink(os.readlink(src), dest) else: @@ -556,7 +556,7 @@ if s2 == s1: return False return True - except: + except OSError: return True _fspathcache = {}
--- a/mercurial/windows.py Sun Apr 24 17:52:46 2011 -0500 +++ b/mercurial/windows.py Sat Apr 23 00:51:25 2011 +0300 @@ -32,7 +32,8 @@ def close(self): try: self.fp.close() - except: pass + except IOError: + pass def write(self, s): try: @@ -243,7 +244,7 @@ if osutil.listdir(head): return os.rmdir(head) - except: + except (ValueError, OSError): break head, tail = os.path.split(head)