]> git.proxmox.com Git - mirror_ovs.git/commitdiff
python: Fix invalid escape sequences.
authorBen Pfaff <blp@ovn.org>
Thu, 10 Jan 2019 23:23:45 +0000 (15:23 -0800)
committerBen Pfaff <blp@ovn.org>
Fri, 11 Jan 2019 16:45:04 +0000 (08:45 -0800)
It appears that Python silently treats invalid escape sequences in
strings as literals, e.g. "\." is the same as "\\.".  Newer versions of
checkpatch complain, and it does seem reasonable to me to fix these.

Acked-by: Numan Siddique <nusiddiq@redhat.com>
Tested-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
python/build/nroff.py
python/ovs/db/schema.py
python/ovs/json.py
python/ovs/unixctl/__init__.py
python/ovs/util.py
python/ovs/vlog.py
tests/test-ovsdb.py
utilities/checkpatch.py
utilities/ovs-dev.py

index 78e4eae6aee4f3a66f584f805984f0380e07a435..a949077570e96ee928157cd46cfca38e57e8412c 100644 (file)
@@ -274,7 +274,7 @@ def diagram_to_nroff(nodes, para):
     text_s = '.br\n'.join(["\\fL%s\n" % s for s in text if s != ""])
     return para + """
 .\\" check if in troff mode (TTY)
-.if t \{
+.if t \\{
 .PS
 boxht = .2
 textht = 1/6
@@ -283,7 +283,7 @@ fillval = .2
 .PE
 \\}
 .\\" check if in nroff mode:
-.if n \{
+.if n \\{
 .nf
 """ + text_s + """\
 .fi
index 55c8ae7f353181d0385c1b6f86a0d36d95f45cdd..44b030757ef7011760a2e7f1bb22a7c4acfbc5c9 100644 (file)
@@ -73,7 +73,7 @@ class DbSchema(object):
         parser.finish()
 
         if (version is not None and
-            not re.match('[0-9]+\.[0-9]+\.[0-9]+$', version)):
+            not re.match(r'[0-9]+\.[0-9]+\.[0-9]+$', version)):
             raise error.Error('schema version "%s" not in format x.y.z'
                               % version)
 
index e84063fc2ed10f47c7c7d3d0f9f20babc63915f2..94c8e30f365d09ebc5ac889679b0640f1be3a61e 100644 (file)
@@ -177,7 +177,7 @@ class Parser(object):
             return False
 
     __number_re = re.compile("(-)?(0|[1-9][0-9]*)"
-            "(?:\.([0-9]+))?(?:[eE]([-+]?[0-9]+))?$")
+            r"(?:\.([0-9]+))?(?:[eE]([-+]?[0-9]+))?$")
 
     def __lex_finish_number(self):
         s = self.buffer
@@ -234,7 +234,7 @@ class Parser(object):
             self.__error("leading zeros not allowed")
         elif re.match("-([^0-9]|$)", s):
             self.__error("'-' must be followed by digit")
-        elif re.match("-?(0|[1-9][0-9]*)\.([^0-9]|$)", s):
+        elif re.match(r"-?(0|[1-9][0-9]*)\.([^0-9]|$)", s):
             self.__error("decimal point must be followed by digit")
         elif re.search("e[-+]?([^0-9]|$)", s):
             self.__error("exponent must contain at least one digit")
index 025da2a90dacbdb5770686a89bf88875d5e76090..c2e5aca8d6ff9b0d0834089657ee862503ae257b 100644 (file)
@@ -73,7 +73,7 @@ def command_register(name, usage, min_args, max_args, callback, aux):
 def socket_name_from_target(target):
     assert isinstance(target, strtypes)
 
-    """ On Windows an absolute path contains ':' ( i.e: C:\ ) """
+    """ On Windows an absolute path contains ':' ( i.e: C:\\ ) """
     if target.startswith('/') or target.find(':') > -1:
         return 0, target
 
index 411ac99c85a45b4d5272bfa1e363e4ab9a04eb77..3dba022f8e277a57384a287f431ff03b9af3262c 100644 (file)
@@ -31,7 +31,7 @@ def abs_file_name(dir_, file_name):
     This differs from os.path.abspath() in that it will never change the
     meaning of a file name.
 
-    On Windows an absolute path contains ':' ( i.e: C:\ ) """
+    On Windows an absolute path contains ':' ( i.e: C:\\ ) """
     if file_name.startswith('/') or file_name.find(':') > -1:
         return file_name
     else:
index e3cf76dcd9e25d630febc65eb9ad055c51224a17..5b478fc541f7e0bc9f08fddb46d687b623d919d2 100644 (file)
@@ -142,7 +142,7 @@ class Vlog(object):
         return re.sub(match, replace, tmp)
 
     def _format_time(self, tmp):
-        date_regex = re.compile('(%(0?[1-9]?[dD])(\{(.*)\})?)')
+        date_regex = re.compile(r'(%(0?[1-9]?[dD])(\{(.*)\})?)')
         match = date_regex.search(tmp)
 
         if match is None:
index 2d1112dddd2b80d541bc1918f4841bf72e03e49a..1d7c023da27dbb0527457f1d741fb451b3c5a9eb 100644 (file)
@@ -167,7 +167,7 @@ def get_simple_printable_row_string(row, columns):
             s += "%s=%s " % (column, value)
     s = s.strip()
     s = re.sub('""|,|u?\'', "", s)
-    s = re.sub('UUID\(([^)]+)\)', r'\1', s)
+    s = re.sub(r'UUID\(([^)]+)\)', r'\1', s)
     s = re.sub('False', 'false', s)
     s = re.sub('True', 'true', s)
     s = re.sub(r'(ba)=([^[][^ ]*) ', r'\1=[\2] ', s)
index 41676adab37510a88d1104b77f021cc3e65d02b1..d8bd34b1f19b134e81342314002c90b05a116142 100755 (executable)
@@ -518,38 +518,38 @@ checks = [
      'check': lambda x: trailing_whitespace_or_crlf(x),
      'print': lambda: print_warning("Line has trailing whitespace")},
 
-    {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
+    {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
      'prereq': lambda x: not is_comment_line(x),
      'check': lambda x: not if_and_for_whitespace_checks(x),
      'print': lambda: print_error("Improper whitespace around control block")},
 
-    {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
+    {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
      'prereq': lambda x: not is_comment_line(x),
      'check': lambda x: not if_and_for_end_with_bracket_check(x),
      'print': lambda: print_error("Inappropriate bracing around statement")},
 
-    {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
+    {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
      'prereq': lambda x: not is_comment_line(x),
      'check': lambda x: pointer_whitespace_check(x),
      'print':
      lambda: print_error("Inappropriate spacing in pointer declaration")},
 
-    {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
+    {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
      'prereq': lambda x: not is_comment_line(x),
      'check': lambda x: trailing_operator(x),
      'print':
      lambda: print_error("Line has '?' or ':' operator at end of line")},
 
-    {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
+    {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
      'prereq': lambda x: has_comment(x),
      'check': lambda x: has_xxx_mark(x),
      'print': lambda: print_warning("Comment with 'xxx' marker")},
 
-    {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
+    {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
      'prereq': lambda x: has_comment(x),
      'check': lambda x: check_comment_spelling(x)},
 
-    {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
+    {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
      'check': lambda x: empty_return_with_brace(x),
      'interim_line': True,
      'print':
@@ -584,7 +584,7 @@ std_functions = [
         ('error', 'Use ovs_error() in place of error()'),
 ]
 checks += [
-    {'regex': '(\.c|\.h)(\.in)?$',
+    {'regex': r'(\.c|\.h)(\.in)?$',
      'match_name': None,
      'prereq': lambda x: not is_comment_line(x),
      'check': regex_function_factory(function_name),
@@ -601,11 +601,11 @@ infix_operators = \
     [re.escape(op) for op in ['%', '<<', '>>', '<=', '>=', '==', '!=',
             '^', '|', '&&', '||', '?:', '=', '+=', '-=', '*=', '/=', '%=',
             '&=', '^=', '|=', '<<=', '>>=']] \
-    + ['[^<" ]<[^=" ]', '[^->" ]>[^=" ]', '[^ !()/"]\*[^/]', '[^ !&()"]&',
-       '[^" +(]\+[^"+;]', '[^" -(]-[^"->;]', '[^" <>=!^|+\-*/%&]=[^"=]',
+    + ['[^<" ]<[^=" ]', '[^->" ]>[^=" ]', r'[^ !()/"]\*[^/]', '[^ !&()"]&',
+       r'[^" +(]\+[^"+;]', '[^" -(]-[^"->;]', r'[^" <>=!^|+\-*/%&]=[^"=]',
        '[^* ]/[^* ]']
 checks += [
-    {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
+    {'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
      'prereq': lambda x: not is_comment_line(x),
      'check': regex_operator_factory(operator),
      'print': lambda: print_warning("Line lacks whitespace around operator")}
@@ -694,7 +694,7 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None):
     current_file = filename if checking_file else ''
     previous_file = ''
     seppatch = re.compile(r'^---([\w]*| \S+)$')
-    hunks = re.compile('^(---|\+\+\+) (\S+)')
+    hunks = re.compile(r'^(---|\+\+\+) (\S+)')
     hunk_differences = re.compile(
         r'^@@ ([0-9-+]+),([0-9-+]+) ([0-9-+]+),([0-9-+]+) @@')
     is_author = re.compile(r'^(Author|From): (.*)$', re.I | re.M | re.S)
index 9ce0f04c7d8a94974c4a9fe0a22f6c85e573d047..248d22ab9a7e8b1fe7488b4c51bce9283264fd46 100755 (executable)
@@ -325,7 +325,7 @@ def modinst():
 
     _sh("modprobe", "openvswitch")
     _sh("dmesg | grep openvswitch | tail -1")
-    _sh("find /lib/modules/%s/ -iname vport-*.ko -exec insmod '{}' \;"
+    _sh("find /lib/modules/%s/ -iname vport-*.ko -exec insmod '{}' \\;"
         % uname())