diff mbox

[1/3] qemu.py: Use items() instead of iteritems()

Message ID 20180312185503.5746-2-ehabkost@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eduardo Habkost March 12, 2018, 6:55 p.m. UTC
items() is less efficient on Python 2.x, but makes the code work
on both Python 2 and Python 3.

Cc: Lukáš Doktor <ldoktor@redhat.com>
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Cc: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel P. Berrangé March 12, 2018, 7:24 p.m. UTC | #1
On Mon, Mar 12, 2018 at 03:55:01PM -0300, Eduardo Habkost wrote:
> items() is less efficient on Python 2.x, but makes the code work
> on both Python 2 and Python 3.
> 
> Cc: Lukáš Doktor <ldoktor@redhat.com>
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Cc: Cleber Rosa <crosa@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  scripts/qemu.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/qemu.py b/scripts/qemu.py
> index 305a946562..08a3e9af5a 100644
> --- a/scripts/qemu.py
> +++ b/scripts/qemu.py
> @@ -277,7 +277,7 @@ class QEMUMachine(object):
>      def qmp(self, cmd, conv_keys=True, **args):
>          '''Invoke a QMP command and return the response dict'''
>          qmp_args = dict()
> -        for key, value in args.iteritems():
> +        for key, value in args.items():
>              if conv_keys:
>                  qmp_args[key.replace('_', '-')] = value
>              else:

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Regards,
Daniel
Philippe Mathieu-Daudé March 12, 2018, 11:02 p.m. UTC | #2
On 03/12/2018 07:55 PM, Eduardo Habkost wrote:
> items() is less efficient on Python 2.x, but makes the code work
> on both Python 2 and Python 3.
> 
> Cc: Lukáš Doktor <ldoktor@redhat.com>
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Cc: Cleber Rosa <crosa@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  scripts/qemu.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/qemu.py b/scripts/qemu.py
> index 305a946562..08a3e9af5a 100644
> --- a/scripts/qemu.py
> +++ b/scripts/qemu.py
> @@ -277,7 +277,7 @@ class QEMUMachine(object):
>      def qmp(self, cmd, conv_keys=True, **args):
>          '''Invoke a QMP command and return the response dict'''
>          qmp_args = dict()
> -        for key, value in args.iteritems():
> +        for key, value in args.items():
>              if conv_keys:
>                  qmp_args[key.replace('_', '-')] = value
>              else:
> 

http://lists.nongnu.org/archive/html/qemu-devel/2017-12/msg04046.html

;)
Eduardo Habkost March 13, 2018, 1:25 a.m. UTC | #3
On Tue, Mar 13, 2018 at 12:02:39AM +0100, Philippe Mathieu-Daudé wrote:
> On 03/12/2018 07:55 PM, Eduardo Habkost wrote:
> > items() is less efficient on Python 2.x, but makes the code work
> > on both Python 2 and Python 3.
> > 
> > Cc: Lukáš Doktor <ldoktor@redhat.com>
> > Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Cc: Cleber Rosa <crosa@redhat.com>
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  scripts/qemu.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/qemu.py b/scripts/qemu.py
> > index 305a946562..08a3e9af5a 100644
> > --- a/scripts/qemu.py
> > +++ b/scripts/qemu.py
> > @@ -277,7 +277,7 @@ class QEMUMachine(object):
> >      def qmp(self, cmd, conv_keys=True, **args):
> >          '''Invoke a QMP command and return the response dict'''
> >          qmp_args = dict()
> > -        for key, value in args.iteritems():
> > +        for key, value in args.items():
> >              if conv_keys:
> >                  qmp_args[key.replace('_', '-')] = value
> >              else:
> > 
> 
> http://lists.nongnu.org/archive/html/qemu-devel/2017-12/msg04046.html

Oops, that series had fallen through the cracks, sorry!

I remember merging a series with fixes for Python 3, but now I
see there were two separate series: "Support building with py2 or
py3¨ (already merged), and yours ("iotests: python3
compatibility¨).
diff mbox

Patch

diff --git a/scripts/qemu.py b/scripts/qemu.py
index 305a946562..08a3e9af5a 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -277,7 +277,7 @@  class QEMUMachine(object):
     def qmp(self, cmd, conv_keys=True, **args):
         '''Invoke a QMP command and return the response dict'''
         qmp_args = dict()
-        for key, value in args.iteritems():
+        for key, value in args.items():
             if conv_keys:
                 qmp_args[key.replace('_', '-')] = value
             else: