From 2910ab464d03f1ca390ab49fd3583912ad18845e Mon Sep 17 00:00:00 2001 From: EllieTheYeen <42704150+EllieTheYeen@users.noreply.github.com> Date: Wed, 5 Jul 2023 09:50:35 +0200 Subject: [PATCH 1/2] FIX charset=None was causing SubscriberProtocol.messageReceived to never be called If the charset = None in SubscriberProtocol then SubscriberProtocol .replyReceived will never call SubscriberProtocol.messageReceived due to u"message" when received will not match b"message" and u"pmessage" will not match b"pmessage" inside the if clauses therefore the code where messageReceived is called will never be reached. This is due to types of str and bytes will not match each other even if similar values are inside --- txredisapi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/txredisapi.py b/txredisapi.py index 24774f2..7863d7c 100644 --- a/txredisapi.py +++ b/txredisapi.py @@ -1916,9 +1916,9 @@ def messageReceived(self, pattern, channel, message): def replyReceived(self, reply): if isinstance(reply, list): reply_len = len(reply) - if reply_len >= 3 and reply[-3] == u"message": + if reply_len >= 3 and reply[-3] in (u"message", b"message"): self.messageReceived(None, *reply[-2:]) - elif reply_len >= 4 and reply[-4] == u"pmessage": + elif reply_len >= 4 and reply[-4] in (u"pmessage", b"pmessage"): self.messageReceived(*reply[-3:]) elif reply_len >= 3 and reply[-3] in self._sub_unsub_reponses and len(self.replyQueue.waiting) == 0: pass From 0802931a6481f7221d27e70e2bb767493833878c Mon Sep 17 00:00:00 2001 From: EllieTheYeen <42704150+EllieTheYeen@users.noreply.github.com> Date: Wed, 5 Jul 2023 18:35:03 +0200 Subject: [PATCH 2/2] Update txredisapi.py --- txredisapi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/txredisapi.py b/txredisapi.py index 7863d7c..0d752e4 100644 --- a/txredisapi.py +++ b/txredisapi.py @@ -1908,7 +1908,8 @@ def stop(self): class SubscriberProtocol(RedisProtocol): - _sub_unsub_reponses = set([u"subscribe", u"unsubscribe", u"psubscribe", u"punsubscribe"]) + _sub_unsub_reponses = set([u"subscribe", u"unsubscribe", u"psubscribe", u"punsubscribe", + b"subscribe", b"unsubscribe", b"psubscribe", b"punsubscribe"]) def messageReceived(self, pattern, channel, message): pass