From 1cd7ccbfa4870a88ae29391755874322cb0d8ae4 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 30 Aug 2003 18:39:19 +0000 Subject: [PATCH] Found bug in perlReToPythonRe and fixed it. --- src/utils.py | 2 +- test/test_utils.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.py b/src/utils.py index ae2bc2280..476b3bbf0 100755 --- a/src/utils.py +++ b/src/utils.py @@ -227,7 +227,7 @@ def perlReToPythonRe(s): flag = 0 try: for c in flags.upper(): - flag &= getattr(re, c) + flag |= getattr(re, c) except AttributeError: raise ValueError, 'Invalid flag: %s' % c return re.compile(regexp, flag) diff --git a/test/test_utils.py b/test/test_utils.py index 5446bf1eb..1e2eef0c4 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -113,6 +113,8 @@ class UtilsTest(unittest.TestCase): self.failUnless(r.search('foo')) r = utils.perlReToPythonRe('m/\\//') self.failUnless(r.search('/')) + r = utils.perlReToPythonRe('m/cat/i') + self.failUnless(r.search('CAT')) def testPerlReToReplacer(self): f = utils.perlReToReplacer('s/foo/bar/') @@ -127,6 +129,8 @@ class UtilsTest(unittest.TestCase): self.assertEqual(f('foobarbaz'), 'foorz') f = utils.perlReToReplacer('s/ba\\///g') self.assertEqual(f('fooba/rba/z'), 'foorz') + f = utils.perlReToReplacer('s/cat/dog/i') + self.assertEqual(f('CATFISH'), 'dogFISH') def testFindBinaryInPath(self): if os.name == 'posix':