mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Made perlReToPythonRe always raise a ValueError instead of re.error.
This commit is contained in:
parent
388e17130d
commit
ed3d757081
@ -211,7 +211,10 @@ def perlReToPythonRe(s):
|
||||
flag |= getattr(re, c)
|
||||
except AttributeError:
|
||||
raise ValueError, 'Invalid flag: %s' % c
|
||||
return re.compile(regexp, flag)
|
||||
try:
|
||||
return re.compile(regexp, flag)
|
||||
except re.error, e:
|
||||
raise ValueError, str(e)
|
||||
|
||||
def perlReToReplacer(s):
|
||||
"""Converts a string representation of a Perl regular expression (i.e.,
|
||||
|
@ -118,6 +118,7 @@ class UtilsTest(unittest.TestCase):
|
||||
self.failUnless(r.search('/'))
|
||||
r = utils.perlReToPythonRe('m/cat/i')
|
||||
self.failUnless(r.search('CAT'))
|
||||
self.assertRaises(ValueError, utils.perlReToPythonRe, 'm/?/')
|
||||
|
||||
def testPerlReToReplacer(self):
|
||||
f = utils.perlReToReplacer('s/foo/bar/')
|
||||
|
Loading…
Reference in New Issue
Block a user