python: Don't use deprecated escape sequences
authorAndreas Schneider <asn@samba.org>
Thu, 19 Jan 2023 07:30:19 +0000 (08:30 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 20 Jan 2023 09:06:49 +0000 (09:06 +0000)
Certain escape sequences are not valid in Python string literals, and
will eventually result in a SyntaxError.

Follow up patch of 5045382c6dd04b1bae0eaaae823be908213ff079

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jan 20 09:06:49 UTC 2023 on atb-devel-224

buildtools/wafsamba/configure_file.py
buildtools/wafsamba/pkgconfig.py
buildtools/wafsamba/samba_abi.py
buildtools/wafsamba/samba_conftests.py
buildtools/wafsamba/samba_headers.py
buildtools/wafsamba/samba_utils.py
buildtools/wafsamba/symbols.py

index 6ad43546249fba7b4c0a037035e8574e7a9d2753..98a58a4604513e3633317e73299c1c9280c250d2 100644 (file)
@@ -13,10 +13,10 @@ def subst_at_vars(task):
     s = task.inputs[0].read()
 
     # split on the vars
-    a = re.split('(@\w+@)', s)
+    a = re.split(r'(@\w+@)', s)
     out = []
     for v in a:
-        if re.match('@\w+@', v):
+        if re.match(r'@\w+@', v):
             vname = v[1:-1]
             if not vname in task.env and vname.upper() in task.env:
                 vname = vname.upper()
index b83d5f382a58352bb3318b594aa2b45fc02d87d5..b77bd618c8903789c7ba9e64a6972a4e080f1821 100644 (file)
@@ -9,12 +9,12 @@ def subst_at_vars(task):
 
     s = task.inputs[0].read()
     # split on the vars
-    a = re.split('(@\w+@)', s)
+    a = re.split(r'(@\w+@)', s)
     out = []
     done_var = {}
     back_sub = [ ('PREFIX', '${prefix}'), ('EXEC_PREFIX', '${exec_prefix}')]
     for v in a:
-        if re.match('@\w+@', v):
+        if re.match(r'@\w+@', v):
             vname = v[1:-1]
             if not vname in task.env and vname.upper() in task.env:
                 vname = vname.upper()
index 80643aa28d7d7a09f2cb32ce2ff1614c566c2e0e..6a8e4bcef00af517d984f1a094c2522c88078e39 100644 (file)
@@ -21,16 +21,16 @@ version_key = lambda x: list(map(int, x.split(".")))
 def normalise_signature(sig):
     '''normalise a signature from gdb'''
     sig = sig.strip()
-    sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}$', r'\1', sig)
-    sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}(\s0x[0-9a-f]+\s<\w+>)+$', r'\1', sig)
-    sig = re.sub('^\$[0-9]+\s=\s(0x[0-9a-f]+)\s?(<\w+>)?$', r'\1', sig)
-    sig = re.sub('0x[0-9a-f]+', '0xXXXX', sig)
+    sig = re.sub(r'^\$[0-9]+\s=\s\{(.+)\}$', r'\1', sig)
+    sig = re.sub(r'^\$[0-9]+\s=\s\{(.+)\}(\s0x[0-9a-f]+\s<\w+>)+$', r'\1', sig)
+    sig = re.sub(r'^\$[0-9]+\s=\s(0x[0-9a-f]+)\s?(<\w+>)?$', r'\1', sig)
+    sig = re.sub(r'0x[0-9a-f]+', '0xXXXX', sig)
     sig = re.sub('", <incomplete sequence (\\\\[a-z0-9]+)>', r'\1"', sig)
 
     for t in abi_type_maps:
         # we need to cope with non-word characters in mapped types
         m = t
-        m = m.replace('*', '\*')
+        m = m.replace('*', r'\*')
         if m[-1].isalnum() or m[-1] == '_':
             m += '\\b'
         if m[0].isalnum() or m[0] == '_':
@@ -41,7 +41,7 @@ def normalise_signature(sig):
 
 def normalise_varargs(sig):
     '''cope with older versions of gdb'''
-    sig = re.sub(',\s\.\.\.', '', sig)
+    sig = re.sub(r',\s\.\.\.', '', sig)
     return sig
 
 
index 2c3149c0fa2513c2fd5abcef9216bb581eb2f552..bd309adb0dddea2ec4286eac49f3d74409960bf7 100644 (file)
@@ -398,7 +398,7 @@ WriteMakefile(
 
     if section:
         man = Utils.readf(os.path.join(bdir,'Makefile'))
-        m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
+        m = re.search(r'MAN%sEXT\s+=\s+(\w+)' % section, man)
         if not m:
             conf.end_msg('not found', color='YELLOW')
             return
index 3313960f5f833a82918b6893d498d2af261edab4..78f57772a8201d7a22e3e02a9f762f3d3d916d9f 100644 (file)
@@ -19,7 +19,7 @@ def header_install_path(header, header_path):
     return ''
 
 
-re_header = re.compile('^\s*#\s*include[ \t]*"([^"]+)"', re.I | re.M)
+re_header = re.compile(r'^\s*#\s*include[ \t]*"([^"]+)"', re.I | re.M)
 
 # a dictionary mapping source header paths to public header paths
 header_map = {}
index 45047e18ada8dd65e8bfbb73761162d7aa10e4b0..a7ba2ac4d0dfb2995c362b1925af313ef57a2244 100644 (file)
@@ -237,10 +237,10 @@ def TO_LIST(str, delimiter=None):
 
 def subst_vars_error(string, env):
     '''substitute vars, throw an error if a variable is not defined'''
-    lst = re.split('(\$\{\w+\})', string)
+    lst = re.split(r'(\$\{\w+\})', string)
     out = []
     for v in lst:
-        if re.match('\$\{\w+\}', v):
+        if re.match(r'\$\{\w+\}', v):
             vname = v[2:-1]
             if not vname in env:
                 raise KeyError("Failed to find variable %s in %s in env %s <%s>" % (vname, string, env.__class__, str(env)))
index a6af1ac1485f2a43ace124673b1b5dd6173ca7fb..5fbc0723927a97e4d2faa91c4767fec45dfd9306 100644 (file)
@@ -119,9 +119,9 @@ def find_ldd_path(bld, libname, binary):
 
 
 # some regular expressions for parsing readelf output
-re_sharedlib = re.compile(b'Shared library: \[(.*)\]')
+re_sharedlib = re.compile(rb'Shared library: \[(.*)\]')
 # output from readelf could be `Library rpath` or `Libray runpath`
-re_rpath     = re.compile(b'Library (rpath|runpath): \[(.*)\]')
+re_rpath     = re.compile(rb'Library (rpath|runpath): \[(.*)\]')
 
 def get_libs(bld, binname):
     '''find the list of linked libraries for any binary or library