diff mbox

[08/11] qmp.py: Avoid "has_key" usage

Message ID 20170720162815.19802-9-ldoktor@redhat.com
State New
Headers show

Commit Message

Lukáš Doktor July 20, 2017, 4:28 p.m. UTC
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(-)

Comments

Eduardo Habkost July 20, 2017, 6:35 p.m. UTC | #1
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>
Philippe Mathieu-Daudé July 22, 2017, 1:31 a.m. UTC | #2
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']
>   
>
diff mbox

Patch

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']