Skip to content

Commit

Permalink
Fix bad Python regexp escapes
Browse files Browse the repository at this point in the history
Python 3.12 started warning about such escapes. Use r"" to suppress
the warning.
  • Loading branch information
keszybz authored and zpytela committed May 19, 2024
1 parent 7c32f5d commit 8881caf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions support/pyplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
from __future__ import nested_scopes
import sys, string, re, io

re_directive = re.compile("\[\[(.*)\]\]")
re_for_loop = re.compile("for (.*) in (.*)")
re_if = re.compile("if (.*)")
re_elif = re.compile("elif (.*)")
re_def = re.compile("def (.*?)\((.*)\)")
re_call = re.compile("call (.*?)\((.*)\)")
re_exec = re.compile("exec (.*)")
re_comment = re.compile("#(.*)#")
re_directive = re.compile(r"\[\[(.*)\]\]")
re_for_loop = re.compile(r"for (.*) in (.*)")
re_if = re.compile(r"if (.*)")
re_elif = re.compile(r"elif (.*)")
re_def = re.compile(r"def (.*?)\((.*)\)")
re_call = re.compile(r"call (.*?)\((.*)\)")
re_exec = re.compile(r"exec (.*)")
re_comment = re.compile(r"#(.*)#")

############################################################
# Template parser
Expand Down
6 changes: 3 additions & 3 deletions support/segenxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# -> ("interface", "kernel_read_system_state")
# "template(`base_user_template',`"
# -> ("template", "base_user_template")
INTERFACE = re.compile("^\s*(interface|template)\(`(\w*)'")
INTERFACE = re.compile(r"^\s*(interface|template)\(`(\w*)'")

# Matches either a gen_bool or a gen_tunable statement. Will give the tuple:
# ("tunable" or "bool", name, "true" or "false")
Expand All @@ -52,7 +52,7 @@
# -> ("bool", "secure_mode", "false")
# "gen_tunable(allow_kerberos, false)"
# -> ("tunable", "allow_kerberos", "false")
BOOLEAN = re.compile("^\s*gen_(tunable|bool)\(\s*(\w*)\s*,\s*(true|false)\s*\)")
BOOLEAN = re.compile(r"^\s*gen_(tunable|bool)\(\s*(\w*)\s*,\s*(true|false)\s*\)")

# Matches a XML comment in the policy, which is defined as any line starting
# with two # and at least one character of white space. Will give the single
Expand All @@ -63,7 +63,7 @@
# -> ("<summary>")
# "## The domain allowed access. "
# -> ("The domain allowed access.")
XML_COMMENT = re.compile("^##\s+(.*?)\s*$")
XML_COMMENT = re.compile(r"^##\s+(.*?)\s*$")


# FUNCTIONS
Expand Down

0 comments on commit 8881caf

Please sign in to comment.