[Python-checkins] cpython (2.7): 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:19 CET 2012


http://hg.python.org/cpython/rev/3b796bd78e81
changeset: 74927:3b796bd78e81
branch: 2.7
parent: 74922:34445738954b
user: Gregory P. Smith <greg at krypto.org>
date: Mon Feb 13 16:45:47 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 codecs
 import logging
 import os
+import re
 import shutil
 import StringIO
 import sys
@@ -104,10 +105,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.assertRegexpMatches(
- 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

AltStyle によって変換されたページ (->オリジナル) /