diff --git a/src/utils/str.py b/src/utils/str.py index 0429113da..66cc7056f 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -89,7 +89,7 @@ def rsplit(s, sep=None, maxsplit=-1): return s.rsplit(sep, maxsplit) def normalizeWhitespace(s, removeNewline=True): - """Normalizes the whitespace in a string; \s+ becomes one space.""" + r"""Normalizes the whitespace in a string; \s+ becomes one space.""" if not s: return str(s) # not the same reference starts_with_space = (s[0] in ' \n\t\r') @@ -525,7 +525,7 @@ def timestamp(t): def url(url): return url -_formatRe = re.compile('%((?:\d+)?\.\d+f|[bfhiLnpqrsStTuv%])') +_formatRe = re.compile(r'%((?:\d+)?\.\d+f|[bfhiLnpqrsStTuv%])') def format(s, *args, **kwargs): """w00t. diff --git a/test/test_utils.py b/test/test_utils.py index be77d1244..bf4d28c2c 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -308,7 +308,7 @@ class StrTest(SupyTestCase): self.assertEqual(f('fooba\\rba\\z'), 'foorz') f = PRTR('s/cat/dog/i') self.assertEqual(f('CATFISH'), 'dogFISH') - f = PRTR('s/foo/foo\/bar/') + f = PRTR(r's/foo/foo\/bar/') self.assertEqual(f('foo'), 'foo/bar') f = PRTR('s/^/foo/') self.assertEqual(f('bar'), 'foobar') @@ -326,7 +326,7 @@ class StrTest(SupyTestCase): self.assertEqual(f('foobarbaz'), 'barbarbaz') def testPerlReToReplacerBug850931(self): - f = utils.str.perlReToReplacer('s/\b(\w+)\b/\1./g') + f = utils.str.perlReToReplacer(r's/\b(\w+)\b/\1./g') self.assertEqual(f('foo bar baz'), 'foo. bar. baz.') def testCommaAndify(self):