On 03/12/2018 07:55 PM, Eduardo Habkost wrote: > 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 <ehabk...@redhat.com> > --- > scripts/qmp/qmp.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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 >
http://lists.nongnu.org/archive/html/qemu-devel/2017-12/msg04047.html ;)