[PATCH 2 of 2] check-code: detect legacy exception syntax

Gregory Szorc gregory.szorc at gmail.com
Wed Jun 24 00:22:16 CDT 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1435123201 25200
#      Tue Jun 23 22:20:01 2015 -0700
# Node ID e81b2ef5ba3e3d3f1bce3da29515976a52645ac6
# Parent  e465446d585fc9c5a67ef925f6dd6de1c932d8c8
check-code: detect legacy exception syntax

We just rewrote all files to use modern exception syntax. Ban the old
form.

This will detect the "except type, instance" and
"except (type1, type2), instance" forms.

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -280,8 +280,10 @@ pypats = [
     (r'(?i)descend[e]nt', "the proper spelling is descendAnt"),
     (r'\.debug\(\_', "don't mark debug messages for translation"),
     (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"),
     (r'^\s*except\s*:', "naked except clause", r'#.*re-raises'),
+    (r'^\s*except\s([^\(,]+|\([^\)]+\))\s*,',
+     'legacy exception syntax; use "as" instead of ","'),
     (r':\n(    )*( ){1,3}[^ ]', "must indent 4 spaces"),
     (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
      "missing _() in ui message (use () to hide false-positives)"),
     (r'release\(.*wlock, .*lock\)', "wrong lock release order"),


More information about the Mercurial-devel mailing list