diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -29,7 +29,7 @@ def read(repo): sha, refspec = line.strip().split(' ', 1) refspec = encoding.tolocal(refspec) bookmarks[refspec] = repo.changelog.lookup(sha) - except: + except IOError: pass return bookmarks diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -294,7 +294,7 @@ def getremotechanges(ui, repo, other, re if not incoming: try: os.unlink(bundlename) - except: + except OSError: pass return other, None, None, None diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -185,7 +185,7 @@ class changelog(revlog.revlog): try: # various tools did silly things with the time zone field. timezone = int(extra_data[0]) - except: + except ValueError: timezone = 0 extra = {} else: diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -293,7 +293,7 @@ def addremove(repo, pats=[], opts={}, dr good = True try: audit_path(abs) - except: + except (OSError, util.Abort): good = False rel = m.rel(abs) exact = m.exact(abs) diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -805,7 +805,7 @@ class workingctx(changectx): 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 diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -133,7 +133,7 @@ def _runcatch(ui, args): 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: diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -363,7 +363,7 @@ def clone(ui, source, dest=None, pull=Fa try: m = dest_repo.lookup(n) dest_repo._bookmarks[k] = m - except: + except error.RepoLookupError: pass if rb: bookmarks.write(dest_repo) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -549,7 +549,7 @@ class localrepository(repo.repository): try: if len(key) == 20: key = hex(key) - except: + except TypeError: pass raise error.RepoLookupError(_("unknown revision '%s'") % key) diff --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -59,7 +59,7 @@ def set_flags(f, l, x): 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) diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py --- a/mercurial/sshrepo.py +++ b/mercurial/sshrepo.py @@ -167,7 +167,7 @@ class sshrepository(wireproto.wirereposi 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 @@ class sshrepository(wireproto.wirereposi return 1 try: return int(r) - except: + except ValueError: self._abort(error.ResponseError(_("unexpected response:"), r)) instance = sshrepository diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -206,12 +206,12 @@ def tempfilter(s, cmd): 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 @@ def copyfile(src, dest): if os.path.islink(src): try: os.unlink(dest) - except: + except OSError: pass os.symlink(os.readlink(src), dest) else: @@ -556,7 +556,7 @@ def checkcase(path): if s2 == s1: return False return True - except: + except OSError: return True _fspathcache = {} diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -32,7 +32,8 @@ class winstdout(object): def close(self): try: self.fp.close() - except: pass + except IOError: + pass def write(self, s): try: @@ -243,7 +244,7 @@ def _removedirs(name): if osutil.listdir(head): return os.rmdir(head) - except: + except (ValueError, OSError): break head, tail = os.path.split(head)