[Python-checkins] cpython (merge 3.2 -> default): re.escape os.sep so that \ is interpreted properly in the regex.

gregory.p.smith python-checkins at python.org
Tue Feb 14 01:46:17 CET 2012


http://hg.python.org/cpython/rev/a32b55a15d26
changeset:   74925:a32b55a15d26
parent:      74921:f13fbd848d50
parent:      74923:7d8a1497b835
user:        Gregory P. Smith <greg at krypto.org>
date:        Mon Feb 13 16:43:55 2012 -0800
summary:
  re.escape os.sep so that \ is interpreted properly in the regex.

files:
  Lib/lib2to3/tests/test_main.py |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Lib/lib2to3/tests/test_main.py b/Lib/lib2to3/tests/test_main.py
--- a/Lib/lib2to3/tests/test_main.py
+++ b/Lib/lib2to3/tests/test_main.py
@@ -3,6 +3,7 @@
 import io
 import logging
 import os
+import re
 import shutil
 import sys
 import tempfile
@@ -94,10 +95,11 @@
             self.assertIn("Writing converted %s to %s" % (
                     os.path.join(self.py2_src_dir, name),
                     os.path.join(self.py3_dest_dir, name+suffix)), stderr)
+        sep = re.escape(os.sep)
         self.assertRegex(
-                stderr, r"No changes to .*/__init__\.py".replace("/", os.sep))
+                stderr, r"No changes to .*/__init__\.py".replace("/", sep))
         self.assertNotRegex(
-                stderr, r"No changes to .*/trivial\.py".replace("/", os.sep))
+                stderr, r"No changes to .*/trivial\.py".replace("/", sep))
 
     def test_filename_changing_on_output_two_files(self):
         """2to3 two files in one directory with a new output dir."""

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list