From d24e6ce6a9c0b166d553023c3ae60c33cdd5d36d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sat, 3 Apr 2021 22:20:57 +0200 Subject: [PATCH] colors: Do not use [] indexing on re.match objects This indexing (i.e. __getitem__) introduced in Python 3.5 as an alias of the group method, so using it breaks this plugin on older Python versions. In particular, messages containing urls cannot be sent and result in an exception: File "matrix/colors.py", line 106, in lambda m: "a" * len(m[0]), TypeError: '_sre.SRE_Match' object has no attribute '__getitem__' This commit replaces the use of the index operation / __getitem__ with the group method, which is equivalent but supported on all python versions. --- matrix/colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix/colors.py b/matrix/colors.py index 70ab71b..c00bc0d 100644 --- a/matrix/colors.py +++ b/matrix/colors.py @@ -103,7 +103,7 @@ class Formatted(object): # for the indices to be correct. escaped_masked = re.sub( r"\\[\\*_`]|(?:" + url_regex + ")", - lambda m: "a" * len(m[0]), + lambda m: "a" * len(m.group(0)), line )