qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v1] Provided python3 support for qmp.py


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v1] Provided python3 support for qmp.py
Date: Wed, 15 Mar 2017 11:32:06 +0800
User-agent: Mutt/1.7.1 (2016-10-04)

On Mon, Mar 06, 2017 at 02:43:50PM +0300, Joannah Nanjekye wrote:
> From: Joannah Najekye <address@hidden>
> 
> Signed-off-by: Joannah Nanjekye <address@hidden>
> ---
> 
> 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: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]