Skip to content

Commit 8657cb6

Browse files
committed
Fix invalid escape sequences in regex string literals.
Use raw strings for regex patterns in rmlist, transcheck, and contrib scripts so Python 3 does not emit SyntaxWarning on invalid escapes. Fixes #28
1 parent 6d113e6 commit 8657cb6

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

bin/rmlist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def main():
128128

129129
# Remove any held messages for this list
130130
for filename in os.listdir(mm_cfg.DATA_DIR):
131-
cre = re.compile('^heldmsg-%s-\d+\.(pck|txt)$' % re.escape(listname),
131+
cre = re.compile(r'^heldmsg-%s-\d+\.(pck|txt)$' % re.escape(listname),
132132
re.IGNORECASE)
133133
if cre.match(filename):
134134
REMOVABLES.append((os.path.join(mm_cfg.DATA_DIR, filename),

bin/transcheck

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ def check_file(translatedFile, originalFile, html=0, quiet=0):
282282
search also <MM-*> tags if html is not zero"""
283283

284284
if html:
285-
c = TransChecker("(%%|%\([^)]+\)[0-9]*[sd]|</?MM-[^>]+>)", "^%%$")
285+
c = TransChecker(r"(%%|%\([^)]+\)[0-9]*[sd]|</?MM-[^>]+>)", "^%%$")
286286
else:
287-
c = TransChecker("(%%|%\([^)]+\)[0-9]*[sd])", "^%%$")
287+
c = TransChecker(r"(%%|%\([^)]+\)[0-9]*[sd])", "^%%$")
288288

289289
try:
290290
f = open(originalFile)
@@ -328,7 +328,7 @@ def check_po(file, quiet=0):
328328
"scan the po file comparing msgids with msgstrs"
329329
n = 0
330330
p = POParser(file)
331-
c = TransChecker("(%%|%\([^)]+\)[0-9]*[sdu]|%[0-9]*[sdu])", "^%%$")
331+
c = TransChecker(r"(%%|%\([^)]+\)[0-9]*[sdu]|%[0-9]*[sdu])", "^%%$")
332332
while p.parse():
333333
if p.msgstr:
334334
c.reset()
@@ -364,8 +364,8 @@ def main():
364364

365365
lang = args[0]
366366

367-
isHtml = re.compile("\.html$");
368-
isTxt = re.compile("\.txt$");
367+
isHtml = re.compile(r"\.html$");
368+
isTxt = re.compile(r"\.txt$");
369369

370370
numerrors = 0
371371
numfiles = 0

contrib/check_perms_grsecurity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ class CheckFixUid:
157157
except ValueError:
158158
file.insert(file.index("import paths\n")+1, "import CheckFixUid\n")
159159
for i in range(len(file)-1, 0, -1):
160-
object=re.compile("^([ ]*)main\(").search(file[i])
160+
object=re.compile(r"^([ ]*)main\(").search(file[i])
161161
# Special hack to support patching of update
162-
object2=re.compile("^([ ]*).*=[ ]*main\(").search(file[i])
162+
object2=re.compile(r"^([ ]*).*=[ ]*main\(").search(file[i])
163163
if object:
164164
print("Patching " + script)
165165
file.insert(i,

contrib/courier-to-mailman.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def main():
8080
listname = string.lower(local)
8181
types = (("-admin$", "admin"),
8282
("-bounces$", "bounces"),
83-
("-bounces\+.*$", "bounces"), # for VERP
83+
(r"-bounces\+.*$", "bounces"), # for VERP
8484
("-confirm$", "confirm"),
85-
("-confirm\+.*$", "confirm"),
85+
(r"-confirm\+.*$", "confirm"),
8686
("-join$", "join"),
8787
("-leave$", "leave"),
8888
("-owner$", "owner"),

0 commit comments

Comments
 (0)