From 6021f0e6d94dc75d7a6f817776f69c33d2483b7a Mon Sep 17 00:00:00 2001 From: Tasos Sahanidis Date: Sun, 4 Jun 2023 22:51:27 +0300 Subject: [PATCH] String: Display regex error on invalid group reference (#1537) --- plugins/String/plugin.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/plugins/String/plugin.py b/plugins/String/plugin.py index 20cae111d..17517381b 100644 --- a/plugins/String/plugin.py +++ b/plugins/String/plugin.py @@ -218,20 +218,21 @@ class String(callbacks.Plugin): s/regexp/replacement/flags, returns the result of applying such a regexp to . """ - if f('') and len(f(' ')) > len(f(''))+1: # Matches the empty string. - s = _('You probably don\'t want to match the empty string.') - irc.error(s) - else: - t = self.registryValue('re.timeout') - try: - v = process(f, text, timeout=t, pn=self.name(), cn='re') - if isinstance(v, list): - v = format('%L', v) - irc.reply(v) - except commands.ProcessTimeoutError as e: - irc.error("ProcessTimeoutError: %s" % (e,)) - except re.error as e: - irc.error(e.args[0]) + try: + if f('') and len(f(' ')) > len(f(''))+1: # Matches the empty string. + s = _('You probably don\'t want to match the empty string.') + irc.error(s) + else: + t = self.registryValue('re.timeout') + try: + v = process(f, text, timeout=t, pn=self.name(), cn='re') + if isinstance(v, list): + v = format('%L', v) + irc.reply(v) + except commands.ProcessTimeoutError as e: + irc.error("ProcessTimeoutError: %s" % (e,)) + except re.error as e: + irc.error(e.args[0]) re = thread(wrap(re, [first('regexpMatcherMany', 'regexpReplacer'), 'text']))