Patchwork verify: remove unreachable code to reraise KeyboardInterrupt

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 20, 2015, 9:53 a.m.
Message ID <bdb06cd254b9ab4f5d5b.1450605204@mimosa>
Download mbox | patch
Permalink /patch/12185/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 20, 2015, 9:53 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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
Sean Farley - Dec. 20, 2015, 7 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@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

Yep, looks good to me.
Matt Mackall - Dec. 20, 2015, 10:36 p.m.
On Sun, 2015-12-20 at 18:53 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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

Queued for default, thanks.

Patch

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)