From fd7aa571e916f9f4e18753cc0946bd9e42287599 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 1 Sep 2017 18:18:56 -0700 Subject: [PATCH] SedRegex: remove compatibility workaround for Python 2.7.6 and lower From: https://github.com/jlu5/SupyPlugins/commit/c9bcbbb934ed34d51c1f7ee4ee8ed12b26443e5d --- plugins/SedRegex/plugin.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/SedRegex/plugin.py b/plugins/SedRegex/plugin.py index 8043040fc..5a98da9bf 100644 --- a/plugins/SedRegex/plugin.py +++ b/plugins/SedRegex/plugin.py @@ -38,6 +38,7 @@ import supybot.ircdb as ircdb import supybot.utils as utils import re +import sys try: from supybot.i18n import PluginInternationalization @@ -45,11 +46,13 @@ try: except ImportError: _ = lambda x: x -# Note: {0,3} is used for matching the flags instead of "*" to work around a Python bug in versions -# lower than 2.7.6: see https://stackoverflow.com/questions/3675144/regex-error-nothing-to-repeat -# and https://bugs.python.org/issue18647 +if sys.version_info[0] < 3: + raise ImportError('This plugin requires Python 3. For a legacy version of this plugin that still ' + 'supports Python 2, consult the python2-legacy branch at ' + 'https://github.com/GLolol/SupyPlugins/tree/python2-legacy') + SED_REGEX = re.compile(r"^(?:(?P.+?)[:,] )?s(?P[^\w\s])(?P.*?)(?P=delim)" - r"(?P.*?)(?P=delim)(?P[a-z]{0,3})$") + r"(?P.*?)(?P=delim)(?P[a-z]*)$") # Replace newlines and friends with things like literal "\n" (backslash and "n") axe_spaces = utils.str.MultipleReplacer({'\n': '\\n', '\t': '\\t', '\r': '\\r'})