Skip to content

Commit de0d59e

Browse files
author
Mike Stegeman
authored
Fix issue with JSON encoding and decoding. (#2)
1 parent f50bc26 commit de0d59e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

gateway_addon/addon_manager_proxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def send(self, msg_type, data):
115115
self.ipc_client.plugin_socket.send(json.dumps({
116116
'messageType': msg_type,
117117
'data': data,
118-
}))
118+
}).encode('utf-8'))
119119
except NNError as e:
120120
print('AddonManagerProxy: Failed to send message: {}'.format(e))
121121

@@ -141,7 +141,7 @@ def recv(self):
141141
continue
142142

143143
try:
144-
msg = json.loads(msg)
144+
msg = json.loads(msg.decode('utf-8'))
145145
except ValueError:
146146
print('AddonManagerProxy: Error parsing message as JSON')
147147
continue

gateway_addon/ipc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, plugin_id, verbose=False):
3434
'data': {
3535
'pluginId': plugin_id,
3636
}
37-
}))
37+
}).encode('utf-8'))
3838
except NNError as e:
3939
print('IpcClient: Failed to send message: {}'.format(e))
4040
return
@@ -49,7 +49,7 @@ def __init__(self, plugin_id, verbose=False):
4949
print('IpcClient: Received manager message: {}'.format(resp))
5050

5151
try:
52-
resp = json.loads(resp)
52+
resp = json.loads(resp.decode('utf-8'))
5353
if not resp or 'messageType' not in resp or \
5454
resp['messageType'] != 'registerPluginReply':
5555
raise ValueError()

0 commit comments

Comments
 (0)