Skip to content

Commit 581f874

Browse files
committed
Try to fix:
DeprecationWarning: invalid escape sequence \d DeprecationWarning: invalid escape sequence \s DeprecationWarning: invalid escape sequence \) Strings under python 3 are unicode strings rather then "regular" strings as under python 2. So all regexps need to be raw strings. We will see how many I fixed and if I broke any.
1 parent 90c632b commit 581f874

File tree

10 files changed

+19
-19
lines changed

10 files changed

+19
-19
lines changed

roundup/backends/back_anydbm.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ def create_inner(self, **propvalues):
919919
newid = self.db.newid(self.classname)
920920

921921
# validate propvalues
922-
num_re = re.compile('^\d+$')
922+
num_re = re.compile(r'^\d+$')
923923
for key, value in propvalues.items():
924924
if key == self.key:
925925
try:
@@ -1094,7 +1094,7 @@ def get(self, nodeid, propname, default=_marker, cache=1):
10941094
raise ValueError('Journalling is disabled for this class')
10951095
journal = self.db.getjournal(self.classname, nodeid)
10961096
if journal:
1097-
num_re = re.compile('^\d+$')
1097+
num_re = re.compile(r'^\d+$')
10981098
value = journal[0][2]
10991099
if num_re.match(value):
11001100
return value
@@ -1114,7 +1114,7 @@ def get(self, nodeid, propname, default=_marker, cache=1):
11141114
raise ValueError('Journalling is disabled for this class')
11151115
journal = self.db.getjournal(self.classname, nodeid)
11161116
if journal:
1117-
num_re = re.compile('^\d+$')
1117+
num_re = re.compile(r'^\d+$')
11181118
value = journal[-1][2]
11191119
if num_re.match(value):
11201120
return value
@@ -1203,7 +1203,7 @@ def set_inner(self, nodeid, **propvalues):
12031203
node = self.db.getnode(self.classname, nodeid)
12041204
if self.db.RETIRED_FLAG in node:
12051205
raise IndexError
1206-
num_re = re.compile('^\d+$')
1206+
num_re = re.compile(r'^\d+$')
12071207

12081208
# if the journal value is to be different, store it in here
12091209
journalvalues = {}
@@ -1690,7 +1690,7 @@ def getnodeids(self, db=None, retired=None):
16901690
return res
16911691

16921692
def _filter(self, search_matches, filterspec, proptree,
1693-
num_re = re.compile('^\d+$'), retired=False):
1693+
num_re = re.compile(r'^\d+$'), retired=False):
16941694
"""Return a list of the ids of the nodes in this class that
16951695
match the 'filter' spec, sorted by the group spec and then the
16961696
sort spec.

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ def create_inner(self, **propvalues):
15721572
newid = self.db.newid(self.classname)
15731573

15741574
# validate propvalues
1575-
num_re = re.compile('^\d+$')
1575+
num_re = re.compile(r'^\d+$')
15761576
for key, value in propvalues.items():
15771577
if key == self.key:
15781578
try:
@@ -1800,7 +1800,7 @@ def set_inner(self, nodeid, **propvalues):
18001800
node = self.db.getnode(self.classname, nodeid)
18011801
if self.is_retired(nodeid):
18021802
raise IndexError('Requested item is retired')
1803-
num_re = re.compile('^\d+$')
1803+
num_re = re.compile(r'^\d+$')
18041804

18051805
# make a copy of the values dictionary - we'll modify the contents
18061806
propvalues = propvalues.copy()

roundup/cgi/TAL/HTMLParser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
)*
4444
\s* # trailing whitespace
4545
""", re.VERBOSE)
46-
endendtag = re.compile('>')
47-
endtagfind = re.compile('</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')
46+
endendtag = re.compile(r'>')
47+
endtagfind = re.compile(r'</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')
4848

4949

5050
class HTMLParseError(BaseException):

roundup/cgi/TAL/TALGenerator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def emitCondition(self, expr):
305305
self.emit("condition", cexpr, program)
306306

307307
def emitRepeat(self, arg):
308-
m = re.match("(?s)\s*(%s)\s+(.*)\Z" % NAME_RE, arg)
308+
m = re.match(r"(?s)\s*(%s)\s+(.*)\Z" % NAME_RE, arg)
309309
if not m:
310310
raise TALError("invalid repeat syntax: " + repr(arg),
311311
self.position)

roundup/cgi/accept_language.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# regexp for languange-range search
3232
nqlre = "([A-Za-z]+[-[A-Za-z]+]*)$"
3333
# regexp for languange-range search with quality value
34-
qlre = "([A-Za-z]+[-[A-Za-z]+]*);q=([\d\.]+)"
34+
qlre = r"([A-Za-z]+[-[A-Za-z]+]*);q=([\d\.]+)"
3535
# both
3636
lre = re.compile(nqlre + "|" + qlre)
3737

roundup/cgi/form_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, client):
4141
self._ = self.gettext = _translator.gettext
4242
self.ngettext = _translator.ngettext
4343

44-
def parse(self, create=0, num_re=re.compile('^\d+$')):
44+
def parse(self, create=0, num_re=re.compile(r'^\d+$')):
4545
""" Item properties and their values are edited with html FORM
4646
variables and their values. You can:
4747

roundup/cgi/templating.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def classes(self):
376376
m.append(HTMLClass(self._client, item))
377377
return m
378378

379-
num_re = re.compile('^-?\d+$')
379+
num_re = re.compile(r'^-?\d+$')
380380

381381
def lookupIds(db, prop, ids, fail_ok=0, num_re=num_re, do_lookup=True):
382382
""" "fail_ok" should be specified if we wish to pass through bad values
@@ -932,7 +932,7 @@ def journal(self, direction='descending'):
932932
# XXX do this
933933
return []
934934

935-
def history(self, direction='descending', dre=re.compile('^\d+$'),
935+
def history(self, direction='descending', dre=re.compile(r'^\d+$'),
936936
limit=None, showall=False ):
937937
"""Create an html view of the journal for the item.
938938

roundup/configuration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,15 +1132,15 @@ def str2value(self, value):
11321132
"Update issue title if incoming subject of email is different.\n"
11331133
"Setting this to \"no\" will ignore the title part of"
11341134
" the subject\nof incoming email messages.\n"),
1135-
(RegExpOption, "refwd_re", "(\s*\W?\s*(fw|fwd|re|aw|sv|ang)\W)+",
1135+
(RegExpOption, "refwd_re", r"(\s*\W?\s*(fw|fwd|re|aw|sv|ang)\W)+",
11361136
"Regular expression matching a single reply or forward\n"
11371137
"prefix prepended by the mailer. This is explicitly\n"
11381138
"stripped from the subject during parsing."),
11391139
(RegExpOption, "origmsg_re",
1140-
"^[>|\s]*-----\s?Original Message\s?-----$",
1140+
r"^[>|\s]*-----\s?Original Message\s?-----$",
11411141
"Regular expression matching start of an original message\n"
11421142
"if quoted the in body."),
1143-
(RegExpOption, "sign_re", "^[>|\s]*-- ?$",
1143+
(RegExpOption, "sign_re", r"^[>|\s]*-- ?$",
11441144
"Regular expression matching the start of a signature\n"
11451145
"in the message body."),
11461146
(RegExpOption, "eol_re", r"[\r\n]+",

roundup/date.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def __deepcopy__(self, memo):
797797
return Interval((self.sign, self.year, self.month, self.day,
798798
self.hour, self.minute, self.second), translator=self.translator)
799799

800-
def set(self, spec, allowdate=1, interval_re=re.compile('''
800+
def set(self, spec, allowdate=1, interval_re=re.compile(r'''
801801
\s*(?P<s>[-+])? # + or -
802802
\s*((?P<y>\d+\s*)y)? # year
803803
\s*((?P<m>\d+\s*)m)? # month

roundup/hyperdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ class HyperdbValueError(ValueError):
15701570
""" Error converting a raw value into a Hyperdb value """
15711571
pass
15721572

1573-
def convertLinkValue(db, propname, prop, value, idre=re.compile('^\d+$')):
1573+
def convertLinkValue(db, propname, prop, value, idre=re.compile(r'^\d+$')):
15741574
""" Convert the link value (may be id or key value) to an id value. """
15751575
linkcl = db.classes[prop.classname]
15761576
if not idre or not idre.match(value):

0 commit comments

Comments
 (0)