From b60c71ab2ebaba0302f97be5620637018628621c Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 13 Jan 2016 19:25:59 -0500 Subject: [PATCH] Attempt to fix compressed READY to work in both Python2 and Python3. --- discord/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/discord/client.py b/discord/client.py index 094db2d14..d319805b5 100644 --- a/discord/client.py +++ b/discord/client.py @@ -103,9 +103,14 @@ class WebSocket(WebSocketBaseClient): self.dispatch('socket_raw_receive', msg) if msg.is_binary: msg = zlib.decompress(msg.data, 15, 10490000) - msg = msg.decode('utf-8') + if sys.version_info[0] == 2: + msg = str(msg).decode('utf-8') + else: + msg = msg.decode('utf-8') + response = json.loads(msg) + else: + response = json.loads(str(msg)) - response = json.loads(str(msg)) log.debug('WebSocket Event: {}'.format(response)) self.dispatch('socket_response', response)