[Python-checkins] Fix improper use of re.escape() in tests. (GH-4814) (#4817)

Serhiy Storchaka webhook-mailer at python.org
Tue Dec 12 13:49:28 EST 2017


https://github.com/python/cpython/commit/d663549a6a2c50450ba51f393ed6855181a36a9e
commit: d663549a6a2c50450ba51f393ed6855181a36a9e
branch: 2.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2017-12-12T20:49:18+02:00
summary:

Fix improper use of re.escape() in tests. (GH-4814) (#4817)

(cherry picked from commit b748e3b2586e44bfc7011b601bce9cc6d16d89f1)

files:
M Lib/test/test_re.py

diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 174c5ca462c..ae314841c68 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -58,7 +58,7 @@ def test_basic_re_sub(self):
 
         s = r"\1\1"
         self.assertEqual(re.sub('(.)', s, 'x'), 'xx')
-        self.assertEqual(re.sub('(.)', re.escape(s), 'x'), s)
+        self.assertEqual(re.sub('(.)', s.replace('\\', r'\\'), 'x'), s)
         self.assertEqual(re.sub('(.)', lambda m: s, 'x'), s)
 
         self.assertEqual(re.sub('(?P<a>x)', '\g<a>\g<a>', 'xx'), 'xxxx')



More information about the Python-checkins mailing list