From c1990a92ed68e157bfef3ef8e2f986ca5e039745 Mon Sep 17 00:00:00 2001 From: Arne Schauf Date: Thu, 17 Sep 2015 15:54:44 +0200 Subject: [PATCH] decode incoming data before loading --- channels/backends/redis_py.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/channels/backends/redis_py.py b/channels/backends/redis_py.py index 6af662f..315c026 100644 --- a/channels/backends/redis_py.py +++ b/channels/backends/redis_py.py @@ -27,6 +27,10 @@ class RedisChannelBackend(BaseChannelBackend): return redis.Redis(host=self.host, port=self.port) def send(self, channel, message): + # if channel is no str (=> bytes) convert it + if not isinstance(channel, str): + channel = channel.decode('utf-8') + # Write out message into expiring key (avoids big items in list) key = self.prefix + uuid.uuid4().get_hex() self.connection.set( @@ -59,7 +63,7 @@ class RedisChannelBackend(BaseChannelBackend): content = self.connection.get(result[1]) if content is None: continue - return result[0][len(self.prefix):], json.loads(content) + return result[0][len(self.prefix):].decode("utf-8"), json.loads(content.decode("utf-8")) else: return None, None