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

Gregory Szorc gregory.szorc at gmail.com
Wed Jun 24 00:41:04 CDT 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1435124301 25200
#      Tue Jun 23 22:38:21 2015 -0700
# Node ID 139ce3ea0c1c3fe46d4a185b6a9b0c8b55292757
# Parent  7f0d2282983cf202b8a1d7667ff15a6e16ce1307
check-code: detect legacy octal syntax

Now that we have mass rewriting all files to use the modern octal
syntax, detect and ban the legacy syntax, which is no longer supported
in Python 3.

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -289,8 +289,9 @@ pypats = [
     (r'release\(.*wlock, .*lock\)', "wrong lock release order"),
     (r'\b__bool__\b', "__bool__ should be __nonzero__ in Python 2"),
     (r'os\.path\.join\(.*, *(""|\'\')\)',
      "use pathutil.normasprefix(path) instead of os.path.join(path, '')"),
+    (r'\s0[0-7]+\b', 'legacy octal syntax; use "0o" prefix instead of "0"'),
   ],
   # warnings
   [
     (r'(^| )pp +xxxxqq[ \n][^\n]', "add two newlines after '.. note::'"),


More information about the Mercurial-devel mailing list