Skip to content

Commit 192d78f

Browse files
committed
bob: correctly encode regex
Use raw strings to stop relying on the fact that unrecognized escape sequences in strings are left unchanged (e.g. "\S"). This behaviour was deprecated in Python 3.6 and will eventually lead to a SyntaxError in the future.
1 parent ea36ae4 commit 192d78f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pym/bob/cmds/build/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _downloadArgument(arg):
3939
return arg
4040
raise argparse.ArgumentTypeError("{} invalid.".format(arg))
4141
def _downloadLayerArgument(arg):
42-
if re.match('^(yes|no|forced)=\S+$', arg):
42+
if re.match(r'^(yes|no|forced)=\S+$', arg):
4343
return arg
4444
raise argparse.ArgumentTypeError("{} invalid.".format(arg))
4545

pym/bob/generators/VisualStudio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
Project("{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}") = "{NAME}", "{NAME}\\{NAME}.vcxproj", "{{{GUID}}}"
4343
EndProject"""
4444

45-
PROJECT_TEMPLATE = """\
45+
PROJECT_TEMPLATE = r"""\
4646
<?xml version="1.0" encoding="utf-8"?>
4747
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4848
<ItemGroup Label="ProjectConfigurations">

test/test_input_stringparser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ def testMatch(self):
167167
self.assertEqual(funMatch(["xyyz", "^xy{1}z$"]), "false")
168168
self.assertEqual(funMatch(["abc", "."]), "true")
169169
self.assertEqual(funMatch(["abc", ".+"]), "true")
170-
self.assertEqual(funMatch([".", "\."]), "true")
171-
self.assertEqual(funMatch(["a.", "^\."]), "false")
172-
self.assertEqual(funMatch(["(a)", "\(a"]), "true")
173-
self.assertEqual(funMatch(["(a)", "\(a$"]), "false")
174-
self.assertEqual(funMatch(["\\a)", "\\\\a\)"]), "true")
170+
self.assertEqual(funMatch([".", r"\."]), "true")
171+
self.assertEqual(funMatch(["a.", r"^\."]), "false")
172+
self.assertEqual(funMatch(["(a)", r"\(a"]), "true")
173+
self.assertEqual(funMatch(["(a)", r"\(a$"]), "false")
174+
self.assertEqual(funMatch([r"\a)", r"\\a\)"]), "true")
175175
self.assertEqual(funMatch(["ABC", "a", "i"]), "true")
176176
self.assertRaises(ParseError, funMatch, ["a"])
177177
self.assertRaises(ParseError, funMatch, ["a","b","x"])

0 commit comments

Comments
 (0)