aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2018-03-12 15:55:02 -0300
committerEduardo Habkost <ehabkost@redhat.com>2018-03-12 19:10:16 -0300
commit7e2b34f26e2c25e94974e37974bc683dce5f8757 (patch)
treeb2e430ae0966922f236c29fb0eda22e4b3ded29c /scripts
parentfb2e1cc6c45fd69082a4793a662778c7a747c452 (diff)
qmp.py: Encode json data before sending
On Python 3, json.dumps() return a str object, which can't be sent directly through a socket and must be encoded into a bytes object. Use .encode('utf-8'), which will work on both Python 2 and Python 3. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20180312185503.5746-3-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qmp/qmp.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/qmp/qmp.py b/scripts/qmp/qmp.py
index 07c9632e9e..5c8cf6a056 100644
--- a/scripts/qmp/qmp.py
+++ b/scripts/qmp/qmp.py
@@ -166,7 +166,7 @@ class QEMUMonitorProtocol(object):
"""
self.logger.debug(">>> %s", qmp_cmd)
try:
- self.__sock.sendall(json.dumps(qmp_cmd))
+ self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8'))
except socket.error as err:
if err[0] == errno.EPIPE:
return