[Qemu-devel] [PATCH 08/11] qmp.py: Avoid "has_key" usage

Lukáš Doktor posted 11 patches 8 years, 6 months ago
There is a newer version of this series
[Qemu-devel] [PATCH 08/11] qmp.py: Avoid "has_key" usage
Posted by Lukáš Doktor 8 years, 6 months ago
The "has_key" is deprecated in favor of "__in__" operator.

Signed-off-by: Lukáš Doktor <ldoktor@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 68f3420..a14b001 100644
--- a/scripts/qmp/qmp.py
+++ b/scripts/qmp/qmp.py
@@ -197,7 +197,7 @@ class QEMUMonitorProtocol(object):
         Build and send a QMP command to the monitor, report errors when any
         """
         ret = self.cmd(cmd, kwds)
-        if ret.has_key('error'):
+        if "error" in ret:
             raise Exception(ret['error']['desc'])
         return ret['return']
 
-- 
2.9.4


Re: [Qemu-devel] [PATCH 08/11] qmp.py: Avoid "has_key" usage
Posted by Eduardo Habkost 8 years, 6 months ago
On Thu, Jul 20, 2017 at 06:28:12PM +0200, Lukáš Doktor wrote:
> The "has_key" is deprecated in favor of "__in__" operator.
> 
> Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

Re: [Qemu-devel] [PATCH 08/11] qmp.py: Avoid "has_key" usage
Posted by Philippe Mathieu-Daudé 8 years, 6 months ago
On 07/20/2017 01:28 PM, Lukáš Doktor wrote:
> The "has_key" is deprecated in favor of "__in__" operator.
> 
> Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   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 68f3420..a14b001 100644
> --- a/scripts/qmp/qmp.py
> +++ b/scripts/qmp/qmp.py
> @@ -197,7 +197,7 @@ class QEMUMonitorProtocol(object):
>           Build and send a QMP command to the monitor, report errors when any
>           """
>           ret = self.cmd(cmd, kwds)
> -        if ret.has_key('error'):
> +        if "error" in ret:
>               raise Exception(ret['error']['desc'])
>           return ret['return']
>   
>