This commit is contained in:
Jeremy Fincher 2003-11-25 09:13:28 +00:00
parent 86b41dd4a6
commit 210809ab99
3 changed files with 14 additions and 2 deletions

View File

@ -1,3 +1,6 @@
* Fixed bug #848475 -- bad error message from regexp-expecting
commands.
* Stopped listing the plugin dispatcher command in the list of
commands for that plugin.

View File

@ -209,7 +209,10 @@ def perlReToPythonRe(s):
"""Converts a string representation of a Perl regular expression (i.e.,
m/^foo$/i or /foo|bar/) to a Python regular expression.
"""
(kind, regexp, flags) = nonEscapedSlashes.split(s)
try:
(kind, regexp, flags) = nonEscapedSlashes.split(s)
except ValueError: # Unpack list of wrong size.
raise ValueError, 'Must be of the form m/.../ or /.../'
regexp = regexp.replace('\\/', '/')
if kind not in ('', 'm'):
raise ValueError, 'Invalid kind: must be in ("", "m")'
@ -229,7 +232,10 @@ def perlReToReplacer(s):
s/foo/bar/g or s/foo/bar/i) to a Python function doing the equivalent
replacement.
"""
(kind, regexp, replace, flags) = nonEscapedSlashes.split(s)
try:
(kind, regexp, replace, flags) = nonEscapedSlashes.split(s)
except ValueError: # Unpack list of wrong size.
raise ValueError, 'Must be of the form s/.../.../'
replace = replace.replace('\\/', '/')
if kind != 's':
raise ValueError, 'Invalid kind: must be "s"'

View File

@ -73,4 +73,7 @@ class UtilitiesTestCase(PluginTestCase, PluginDocumentation):
self.assertNotRegexp('re m/foo/ bar', 'has no attribute')
self.assertResponse('re m/a\S+y/ "the bot angryman is hairy"','angry')
def testReNoEscapingUnpackListOfWrongSize(self):
self.assertNotRegexp('re foo bar baz', 'unpack list of wrong size')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: