1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

python: use raw string for regex with escape

Python regards 'GPT\.INI$' as a string containing an invalid escape
sequence '\.', which is ignored (i.e. treated as the literal sequence
of those 2 characters), but only after Python has grumbled to itself,
and to you if you enabled DeprecationWarnings.

The proper thing to do here is use r-strings, like r'GPT\.INI$', which
tell Python that all backslashes are literal. Alternatively (as we do
once in this patch), the backslash can itself be escaped ('\\').

There are more problems of this nature in the build scripts.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
Douglas Bagnall
2020-02-07 11:25:27 +13:00
committed by Noel Power
parent c247afbda0
commit 07fa6678e4
5 changed files with 15 additions and 15 deletions

View File

@ -37,7 +37,7 @@ from samba.netcmd import (
Option,
)
RE_RANGED_RESULT = re.compile("^([^;]+);range=(\d+)-(\d+|\*)$")
RE_RANGED_RESULT = re.compile(r"^([^;]+);range=(\d+)-(\d+|\*)$")
class LDAPBase(object):
@ -274,9 +274,9 @@ class Descriptor(object):
"""
try:
if "S:" in self.sddl:
res = re.search("D:(.*?)(\(.*?\))S:", self.sddl).group(2)
res = re.search(r"D:(.*?)(\(.*?\))S:", self.sddl).group(2)
else:
res = re.search("D:(.*?)(\(.*\))", self.sddl).group(2)
res = re.search(r"D:(.*?)(\(.*\))", self.sddl).group(2)
except AttributeError:
return []
return re.findall("(\(.*?\))", res)