From 7adc958dd624f62f3fb65248e0bb9f0a0f5b6287 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 6 Jan 2019 18:06:44 +0100 Subject: [PATCH] Fix SyntaxWarnings on Python 3.8 --- src/utils/str.py | 4 ++-- test/test_utils.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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):