Fixed bug in perlReToReplacer where escaped slashes would stay in the output.

This commit is contained in:
Jeremy Fincher 2003-10-12 13:11:53 +00:00
parent 367569f1c7
commit a0fe5410c0
2 changed files with 3 additions and 0 deletions

View File

@ -219,6 +219,7 @@ def perlReToReplacer(s):
replacement. replacement.
""" """
(kind, regexp, replace, flags) = nonEscapedSlashes.split(s) (kind, regexp, replace, flags) = nonEscapedSlashes.split(s)
replace = replace.replace('\\/', '/')
if kind != 's': if kind != 's':
raise ValueError, 'Invalid kind: must be "s"' raise ValueError, 'Invalid kind: must be "s"'
g = False g = False

View File

@ -134,6 +134,8 @@ class UtilsTest(unittest.TestCase):
self.assertEqual(f('fooba/rba/z'), 'foorz') self.assertEqual(f('fooba/rba/z'), 'foorz')
f = utils.perlReToReplacer('s/cat/dog/i') f = utils.perlReToReplacer('s/cat/dog/i')
self.assertEqual(f('CATFISH'), 'dogFISH') self.assertEqual(f('CATFISH'), 'dogFISH')
f = utils.perlReToReplacer('s/foo/foo\/bar/')
self.assertEqual(f('foo'), 'foo/bar')
def testFindBinaryInPath(self): def testFindBinaryInPath(self):
if os.name == 'posix': if os.name == 'posix':