1 |
commit: b64d2694b612f6962fb43f87557a9562253c68fd |
2 |
Author: Nicolas Iooss <nicolas.iooss <AT> m4x <DOT> org> |
3 |
AuthorDate: Sat Apr 8 09:41:05 2017 +0000 |
4 |
Commit: Sven Vermeulen <swift <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Apr 10 16:58:49 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=b64d2694 |
7 |
|
8 |
Use raw strings in regular expressions |
9 |
|
10 |
Python 3.6 complains about the strings which are used as regular |
11 |
expression in the support scripts: |
12 |
|
13 |
File "support/segenxml.py", line 37 |
14 |
INTERFACE = re.compile("^\s*(interface|template)\(`(\w*)'") |
15 |
^ |
16 |
SyntaxError: invalid escape sequence \s |
17 |
|
18 |
support/pyplate.py | 16 ++++++++-------- |
19 |
support/segenxml.py | 6 +++--- |
20 |
2 files changed, 11 insertions(+), 11 deletions(-) |
21 |
|
22 |
diff --git a/support/pyplate.py b/support/pyplate.py |
23 |
index 28c61088..d0e7fe26 100644 |
24 |
--- a/support/pyplate.py |
25 |
+++ b/support/pyplate.py |
26 |
@@ -54,14 +54,14 @@ PyPlate defines the following directives: |
27 |
|
28 |
import sys, re, io |
29 |
|
30 |
-re_directive = re.compile("\[\[(.*)\]\]") |
31 |
-re_for_loop = re.compile("for (.*) in (.*)") |
32 |
-re_if = re.compile("if (.*)") |
33 |
-re_elif = re.compile("elif (.*)") |
34 |
-re_def = re.compile("def (.*?)\((.*)\)") |
35 |
-re_call = re.compile("call (.*?)\((.*)\)") |
36 |
-re_exec = re.compile("exec (.*)") |
37 |
-re_comment = re.compile("#(.*)#") |
38 |
+re_directive = re.compile(r"\[\[(.*)\]\]") |
39 |
+re_for_loop = re.compile(r"for (.*) in (.*)") |
40 |
+re_if = re.compile(r"if (.*)") |
41 |
+re_elif = re.compile(r"elif (.*)") |
42 |
+re_def = re.compile(r"def (.*?)\((.*)\)") |
43 |
+re_call = re.compile(r"call (.*?)\((.*)\)") |
44 |
+re_exec = re.compile(r"exec (.*)") |
45 |
+re_comment = re.compile(r"#(.*)#") |
46 |
|
47 |
############################################################ |
48 |
# Template parser |
49 |
|
50 |
diff --git a/support/segenxml.py b/support/segenxml.py |
51 |
index 383428df..e37ea041 100644 |
52 |
--- a/support/segenxml.py |
53 |
+++ b/support/segenxml.py |
54 |
@@ -34,7 +34,7 @@ output_dir = "" |
55 |
# -> ("interface", "kernel_read_system_state") |
56 |
# "template(`base_user_template',`" |
57 |
# -> ("template", "base_user_template") |
58 |
-INTERFACE = re.compile("^\s*(interface|template)\(`(\w*)'") |
59 |
+INTERFACE = re.compile(r"^\s*(interface|template)\(`(\w*)'") |
60 |
|
61 |
# Matches either a gen_bool or a gen_tunable statement. Will give the tuple: |
62 |
# ("tunable" or "bool", name, "true" or "false") |
63 |
@@ -43,7 +43,7 @@ INTERFACE = re.compile("^\s*(interface|template)\(`(\w*)'") |
64 |
# -> ("bool", "secure_mode", "false") |
65 |
# "gen_tunable(allow_kerberos, false)" |
66 |
# -> ("tunable", "allow_kerberos", "false") |
67 |
-BOOLEAN = re.compile("^\s*gen_(tunable|bool)\(\s*(\w*)\s*,\s*(true|false)\s*\)") |
68 |
+BOOLEAN = re.compile(r"^\s*gen_(tunable|bool)\(\s*(\w*)\s*,\s*(true|false)\s*\)") |
69 |
|
70 |
# Matches a XML comment in the policy, which is defined as any line starting |
71 |
# with two # and at least one character of white space. Will give the single |
72 |
@@ -54,7 +54,7 @@ BOOLEAN = re.compile("^\s*gen_(tunable|bool)\(\s*(\w*)\s*,\s*(true|false)\s*\)") |
73 |
# -> ("<summary>") |
74 |
# "## The domain allowed access. " |
75 |
# -> ("The domain allowed access.") |
76 |
-XML_COMMENT = re.compile("^##\s+(.*?)\s*$") |
77 |
+XML_COMMENT = re.compile(r"^##\s+(.*?)\s*$") |
78 |
|
79 |
|
80 |
# FUNCTIONS |