All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org, "Lukáš Doktor" <ldoktor@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending
Date: Mon, 12 Mar 2018 19:24:42 +0000	[thread overview]
Message-ID: <20180312192442.GC15677@redhat.com> (raw)
In-Reply-To: <20180312185503.5746-3-ehabkost@redhat.com>

On Mon, Mar 12, 2018 at 03:55:02PM -0300, 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 <ehabkost@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

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

  reply	other threads:[~2018-03-12 19:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 18:55 [Qemu-devel] [PATCH 0/3] scripts: Python 3 compatibility fixes Eduardo Habkost
2018-03-12 18:55 ` [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() Eduardo Habkost
2018-03-12 19:24   ` Daniel P. Berrangé
2018-03-12 23:02   ` Philippe Mathieu-Daudé
2018-03-13  1:25     ` Eduardo Habkost
2018-03-12 18:55 ` [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending Eduardo Habkost
2018-03-12 19:24   ` Daniel P. Berrangé [this message]
2018-03-12 23:03   ` Philippe Mathieu-Daudé
2018-03-12 18:55 ` [Qemu-devel] [PATCH 3/3] device-crash-test: Use 'python' binary Eduardo Habkost
2018-03-12 19:24   ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180312192442.GC15677@redhat.com \
    --to=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=ldoktor@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.