diff --git a/ChangeLog b/ChangeLog index 1a86d93fa..d73d543dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/src/utils.py b/src/utils.py index 5b7a6765c..e71396c12 100755 --- a/src/utils.py +++ b/src/utils.py @@ -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"' diff --git a/test/test_Utilities.py b/test/test_Utilities.py index 0fc602d77..1cd9c6bc9 100644 --- a/test/test_Utilities.py +++ b/test/test_Utilities.py @@ -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: