changeset 18183:e1caaeb5a2ed

check-code: disallow defunct <> operator Added a test for that and one other python3 check in test-check-code.t.
author Augie Fackler <raf@durin42.com>
date Tue, 01 Jan 2013 13:05:22 -0600
parents e6db64abfa87
children 8d48af68e2ae
files contrib/check-code.py tests/test-check-code.t
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Tue Jan 01 13:04:40 2013 -0600
+++ b/contrib/check-code.py	Tue Jan 01 13:05:22 2013 -0600
@@ -129,6 +129,7 @@
     (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
     (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
     (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
+    (r'\s<>\s', '<> operator is not available in Python 3+, use !='),
     (r'^\s*\t', "don't use tabs"),
     (r'\S;\s*\n', "semicolon"),
     (r'[^_]_\("[^"]+"\s*%', "don't use % inside _()"),
--- a/tests/test-check-code.t	Tue Jan 01 13:04:40 2013 -0600
+++ b/tests/test-check-code.t	Tue Jan 01 13:05:22 2013 -0600
@@ -110,6 +110,18 @@
    > class empty():
    class foo() not available in Python 2.4, use class foo(object)
   [1]
+  $ cat > python3-compat.py << EOF
+  > foo <> bar
+  > reduce(lambda a, b: a + b, [1, 2, 3, 4])
+  > EOF
+  $ "$check_code" python3-compat.py
+  python3-compat.py:1:
+   > foo <> bar
+   <> operator is not available in Python 3+, use !=
+  python3-compat.py:2:
+   > reduce(lambda a, b: a + b, [1, 2, 3, 4])
+   reduce is not available in Python 3+
+  [1]
 
   $ cat > is-op.py <<EOF
   > # is-operator comparing number or string literal