poljar / weechat-matrix

Weechat Matrix protocol script written in python
Other
957 stars 119 forks source link

colors: Do not use [] indexing on re.match objects #264

Closed matthijskooijman closed 3 years ago

matthijskooijman commented 3 years ago

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>
    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.