[Python-checkins] Use raw strings for regex to avoid invalid escape sequences. (GH-4741)

Eric V. Smith webhook-mailer at python.org
Wed Dec 6 14:00:37 EST 2017


https://github.com/python/cpython/commit/24e77f92658c7d258e2a3cf9868f3f4658932b40
commit: 24e77f92658c7d258e2a3cf9868f3f4658932b40
branch: master
author: Eric V. Smith <ericvsmith at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2017-12-06T14:00:34-05:00
summary:

Use raw strings for regex to avoid invalid escape sequences. (GH-4741)

files:
M Lib/test/test_dataclasses.py

diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py
index caea98a13b0..9d08a2d4c91 100755
--- a/Lib/test/test_dataclasses.py
+++ b/Lib/test/test_dataclasses.py
@@ -1831,7 +1831,7 @@ class C:
         #  if we're also replacing one that does exist.  Test this
         #  here, because setting attributes on frozen instances is
         #  handled slightly differently from non-frozen ones.
-        with self.assertRaisesRegex(TypeError, "__init__\(\) got an unexpected "
+        with self.assertRaisesRegex(TypeError, r"__init__\(\) got an unexpected "
                                              "keyword argument 'a'"):
             c1 = replace(c, x=20, a=5)
 
@@ -1842,7 +1842,7 @@ class C:
             y: int
 
         c = C(1, 2)
-        with self.assertRaisesRegex(TypeError, "__init__\(\) got an unexpected "
+        with self.assertRaisesRegex(TypeError, r"__init__\(\) got an unexpected "
                                     "keyword argument 'z'"):
             c1 = replace(c, z=3)
 



More information about the Python-checkins mailing list