mirror of
https://github.com/topjohnwu/selinux.git
synced 2024-11-27 21:40:39 +00:00
Python 3.6 invalid escape sequence deprecation fixes
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior A backslash-character pair that is not a valid escape sequence now generates a DeprecationWarning. Although this will eventually become a SyntaxError, that will not be for several Python releases. The problem appears when you use '-W error': $ python3 -W error -c 'import re; re.findall("[^a-zA-Z0-9_\-\.]", " *%$")' File "<string>", line 1 SyntaxError: invalid escape sequence \- Signed-off-by: Ville Skyttä <ville.skytta@iki.fi> [ Edited commit message as per suggestion from Petr Lautrbach ] Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
This commit is contained in:
parent
718bc4bcdf
commit
fba9d01035
@ -192,8 +192,8 @@ class nulllogger:
|
||||
def validate_level(raw):
|
||||
sensitivity = "s[0-9]*"
|
||||
category = "c[0-9]*"
|
||||
cat_range = category + "(\." + category + ")?"
|
||||
categories = cat_range + "(\," + cat_range + ")*"
|
||||
cat_range = category + r"(\." + category + ")?"
|
||||
categories = cat_range + r"(\," + cat_range + ")*"
|
||||
reg = sensitivity + "(-" + sensitivity + ")?" + "(:" + categories + ")?"
|
||||
return re.search("^" + reg + "$", raw)
|
||||
|
||||
|
@ -40,7 +40,7 @@ from . import defaults
|
||||
def is_valid_name(modname):
|
||||
"""Check that a module name is valid.
|
||||
"""
|
||||
m = re.findall("[^a-zA-Z0-9_\-\.]", modname)
|
||||
m = re.findall(r"[^a-zA-Z0-9_\-\.]", modname)
|
||||
if len(m) == 0 and modname[0].isalpha():
|
||||
return True
|
||||
else:
|
||||
|
@ -1329,7 +1329,7 @@ allow %s_t %s_t:%s_socket name_%s;
|
||||
self.add_dir("/var/lib/%s" % self.name)
|
||||
|
||||
if os.path.isfile("/etc/rc.d/init.d/%s" % self.name):
|
||||
self.set_init_script("/etc/rc\.d/init\.d/%s" % self.name)
|
||||
self.set_init_script(r"/etc/rc\.d/init\.d/%s" % self.name)
|
||||
|
||||
# we don't want to have subdir in the .fc policy file
|
||||
# if we already specify labeling for parent dir
|
||||
|
Loading…
Reference in New Issue
Block a user