From: Stefan Hajnoczi <stefanha@redhat.com>
To: Joannah Nanjekye <nanjekyejoannah@gmail.com>
Cc: qemu-devel@nongnu.org, jsnow@redhat.com
Subject: Re: [Qemu-devel] [PATCH v1] Provided python3 support for qmp.py
Date: Wed, 15 Mar 2017 11:32:06 +0800 [thread overview]
Message-ID: <20170315033206.GL13140@stefanha-x1.localdomain> (raw)
In-Reply-To: <1488800630-32054-1-git-send-email-nanjekyejoannah@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1785 bytes --]
On Mon, Mar 06, 2017 at 02:43:50PM +0300, Joannah Nanjekye wrote:
> From: Joannah Najekye <nanjekyejoannah@gmail.com>
>
> Signed-off-by: Joannah Nanjekye <nanjekyejoannah@gmail.com>
> ---
>
> The patch provides python 3 support for one of the scripts in scripts/qmp that is to say qmp.py. This is not a port to python 3 but rather the patch ensures that the script runs fine for both python 2 and 3.
>
> Minimum Python Versions supported:
>
> Python 2 : python 2.6 +
> Python 3 : python 3.3 +
>
> The two new imports future and builtins introduced refer to the future
> pip-installable package on PyPI.
>
> scripts/qmp/qmp.py | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
Did you test your patch with Python 3? Launch QEMU like this:
$ qemu-system-x86_64 -qmp unix:/tmp/foo.sock,server
In another terminal you can launch Python and interactively test the
module like I did above.
I still get the following Python 3 exception with your patch:
$ python3
Python 3.5.2 (default, Sep 14 2016, 11:28:32)
[GCC 6.2.1 20160901 (Red Hat 6.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import qmp
>>> q = qmp.QEMUMonitorProtocol('/tmp/foo.sock')
>>> q.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "qemu/scripts/qmp/qmp.py", line 135, in connect
return self.__negotiate_capabilities()
File "qemu/scripts/qmp/qmp.py", line 61, in __negotiate_capabilities
if greeting is None or not greeting.has_key('QMP'):
AttributeError: 'dict' object has no attribute 'has_key'
In Python 3 the dict object lacks the has_key() method. Please convert
the code to use 'key' in dict instead of dict.has_key('key').
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
prev parent reply other threads:[~2017-03-15 3:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1488800630-32054-1-git-send-email-nanjekyejoannah@gmail.com>
2017-03-15 3:21 ` [Qemu-devel] [PATCH v1] Provided python3 support for qmp.py Stefan Hajnoczi
2017-03-15 3:32 ` Stefan Hajnoczi [this message]
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=20170315033206.GL13140@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=jsnow@redhat.com \
--cc=nanjekyejoannah@gmail.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).