From: Stefan Hajnoczi <stefanha@redhat.com>
To: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
Cc: qemu-devel@nongnu.org, jsnow@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] Python3 Support for qmp.py
Date: Fri, 7 Jul 2017 11:37:03 +0100 [thread overview]
Message-ID: <20170707103703.GA18375@stefanha-x1.localdomain> (raw)
In-Reply-To: <1499368127-19855-1-git-send-email-chugh.ishani@research.iiit.ac.in>
[-- Attachment #1: Type: text/plain, Size: 2470 bytes --]
On Fri, Jul 07, 2017 at 12:38:47AM +0530, Ishani Chugh wrote:
Commit messages usually begin with a prefix indicating the affected
component. This makes it easier for code reviewers and maintainers to
browse email subjects and the git log. I recommend the following commit
message:
scripts/qmp: Python3 Support for qmp.py
> def __json_read(self, only_event=False):
> while True:
> - data = self.__sockfile.readline()
> + data = self.__sock_readline()
> if not data:
> return
> resp = json.loads(data)
> if 'event' in resp:
> if self._debug:
> - print >>sys.stderr, "QMP:<<< %s" % resp
> + print("QMP:<<< %s" % resp)
Previously debug output was printed to stderr. Please do not change
this.
Here is how to keep stderr in Python 2.6+/3 compatible fashion:
from __future__ import print_function
...
print("QMP:<<< %s" % resp, file=sys.stderr)
There are more instances of this below.
> @@ -98,9 +112,11 @@ class QEMUMonitorProtocol:
> try:
> self.__json_read()
> except socket.error as err:
> - if err[0] == errno.EAGAIN:
> + if err.errno == errno.EAGAIN:
> # No data available
> pass
> + else:
> + raise
> self.__sock.setblocking(1)
>
> # Wait for new events, if needed.
The "else: raise" silently fixes a bug. Please mention that socket
errors were silently ignored in the commit description. That will make
the intention of this change clear for anyone who looks at this commit
in the future.
> @@ -175,7 +190,7 @@ class QEMUMonitorProtocol:
> @param args: command arguments (dict)
> @param id: command id (dict, list, string or int)
> """
> - qmp_cmd = { 'execute': name }
> + qmp_cmd = {'execute': name}
> if args:
> qmp_cmd['arguments'] = args
> if id:
Please make PEP8 fixes in a separate commit and only Python 2/3
compatibility changes in this commit. Commits that do only one thing
are easier to understand, backport, and bisect.
> @@ -245,3 +260,4 @@ class QEMUMonitorProtocol:
>
> def is_scm_available(self):
> return self.__sock.family == socket.AF_UNIX
> +
What is the purpose of this extra newline?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2017-07-07 10:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 19:08 [Qemu-devel] [PATCH v2] Python3 Support for qmp.py Ishani Chugh
2017-07-07 10:37 ` Stefan Hajnoczi [this message]
2017-07-07 11:01 ` Daniel P. Berrange
2017-07-13 17:37 ` Ishani
2017-07-07 13:15 ` Markus Armbruster
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=20170707103703.GA18375@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=chugh.ishani@research.iiit.ac.in \
--cc=jsnow@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).