python: Don't use deprecated escape sequences
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 28 Apr 2022 08:31:50 +0000 (20:31 +1200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 14 Jun 2022 07:21:29 +0000 (07:21 +0000)
Certain escape sequences are not valid in Python string literals, and
will eventually result in a SyntaxError.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
buildtools/wafsamba/samba_cross.py
python/samba/netcmd/ldapcmp.py
source4/dsdb/tests/python/acl.py
source4/dsdb/tests/python/sec_descriptor.py

index c6f8c2a0ef2fe1797d41e923273eb6461a1f18cb..7ec1edc52ea50fcf85472033e79689562716efe9 100644 (file)
@@ -77,7 +77,7 @@ def cross_answer(ca_file, msg):
                 f.close()
                 return (0, ans.strip("'"))
             else:
-                m = re.match('\(\s*(-?\d+)\s*,\s*\"(.*)\"\s*\)', ans)
+                m = re.match(r'\(\s*(-?\d+)\s*,\s*\"(.*)\"\s*\)', ans)
                 if m:
                     f.close()
                     return (int(m.group(1)), m.group(2))
index 762047c467b50b1da24a4f1a11a0ee83002338af..dddd5a894be354e39a00a6a08818e51356e96b25 100644 (file)
@@ -279,7 +279,7 @@ class Descriptor(object):
                 res = re.search(r"D:(.*?)(\(.*\))", self.sddl).group(2)
         except AttributeError:
             return []
-        return re.findall("(\(.*?\))", res)
+        return re.findall(r"(\(.*?\))", res)
 
     def fix_sid(self, ace):
         res = "%s" % ace
index 70dca9b7678151e305a5458f0e8d5b4e02781405..1271dfcc9570a0d2c45634fd423ab9d059cdec1d 100755 (executable)
@@ -695,7 +695,7 @@ class AclSearchTests(AclTests):
         # Make sure there are inheritable ACEs initially
         self.assertTrue("CI" in desc_sddl or "OI" in desc_sddl)
         # Find and remove all inherit ACEs
-        res = re.findall("\(.*?\)", desc_sddl)
+        res = re.findall(r"\(.*?\)", desc_sddl)
         res = [x for x in res if ("CI" in x) or ("OI" in x)]
         for x in res:
             desc_sddl = desc_sddl.replace(x, "")
index b67bf33b5f70be179d5ea0416db453e54ab6ed47..6471fc15c55fa9d00a4a377f3454fdc1cff8de93 100755 (executable)
@@ -1248,7 +1248,7 @@ class DaclDescriptorTests(DescriptorTests):
         # Make sure there are inheritable ACEs initially
         self.assertTrue("CI" in desc_sddl or "OI" in desc_sddl)
         # Find and remove all inherit ACEs
-        res = re.findall("\(.*?\)", desc_sddl)
+        res = re.findall(r"\(.*?\)", desc_sddl)
         res = [x for x in res if ("CI" in x) or ("OI" in x)]
         for x in res:
             desc_sddl = desc_sddl.replace(x, "")
@@ -1315,12 +1315,12 @@ class DaclDescriptorTests(DescriptorTests):
         # also make sure the added above non-inheritable ACEs are absent too
         desc_sddl = self.sd_utils.get_sd_as_sddl(group_dn)
         self.assertFalse("ID" in desc_sddl)
-        for x in re.findall("\(.*?\)", mod):
+        for x in re.findall(r"\(.*?\)", mod):
             self.assertFalse(x in desc_sddl)
         self.sd_utils.modify_sd_on_dn(group_dn, "D:" + moded)
         desc_sddl = self.sd_utils.get_sd_as_sddl(group_dn)
         self.assertFalse("ID" in desc_sddl)
-        for x in re.findall("\(.*?\)", mod):
+        for x in re.findall(r"\(.*?\)", mod):
             self.assertFalse(x in desc_sddl)
 
     def test_203(self):