[PATCH] verify: remove unreachable code to reraise KeyboardInterrupt

Yuya Nishihara yuya at tcha.org
Sun Dec 20 09:53:24 UTC 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1450604301 -32400
#      Sun Dec 20 18:38:21 2015 +0900
# Node ID bdb06cd254b9ab4f5d5b928f9a976d953fc8cb04
# Parent  7f38cf67f49e9ac1af8c22f2d57cbd648e2a9d49
verify: remove unreachable code to reraise KeyboardInterrupt

KeyboardInterrupt should never be caught as it doesn't inherit Exception in
Python 2.5 or later. And if it was, "interrupted" would be printed twice.

https://docs.python.org/2.7/library/exceptions.html#exception-hierarchy

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -76,9 +76,6 @@ class verifier(object):
         self.errors[0] += 1
 
     def exc(self, linkrev, msg, inst, filename=None):
-        if isinstance(inst, KeyboardInterrupt):
-            self.ui.warn(_("interrupted"))
-            raise
         if not str(inst):
             inst = repr(inst)
         self.err(linkrev, "%s: %s" % (msg, inst), filename)


More information about the Mercurial-devel mailing list