check-code: extend try/except/finally check for multiple except clauses
authorMatt Mackall <mpm@selenic.com>
Thu, 14 Aug 2014 16:39:27 -0500
changeset 22175 2965804483e3
parent 22174 0cc2db64c335
child 22183 4dd9f606d0a6
check-code: extend try/except/finally check for multiple except clauses
contrib/check-code.py
--- a/contrib/check-code.py	Thu Aug 14 16:39:02 2014 -0500
+++ b/contrib/check-code.py	Thu Aug 14 16:39:27 2014 -0500
@@ -216,8 +216,9 @@
     (r'(\w|\)),\w', "missing whitespace after ,"),
     (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"),
     (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
-    (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
-     r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Python 2.4'),
+    (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)(\1except.*?:\n'
+     r'((?:\n|\1\s.*\n)+?))+\1finally:',
+     'no try/except/finally in Python 2.4'),
     (r'(?<!def)(\s+|^|\()next\(.+\)',
      'no next(foo) in Python 2.4 and 2.5, use foo.next() instead'),
     (r'(\s+)try:\n((?:\n|\1\s.*\n)*?)\1\s*yield\b.*?'