* [Qemu-devel] [PATCH 0/3] scripts: Python 3 compatibility fixes @ 2018-03-12 18:55 Eduardo Habkost 2018-03-12 18:55 ` [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() Eduardo Habkost ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Eduardo Habkost @ 2018-03-12 18:55 UTC (permalink / raw) To: qemu-devel; +Cc: Lukáš Doktor, Cleber Rosa Fix a few incompatibilities, which should be enough to allow device-crash-test to work with Python 3. Eduardo Habkost (3): qemu.py: Use items() instead of iteritems() qmp.py: Encode json data before sending device-crash-test: Use 'python' binary scripts/qemu.py | 2 +- scripts/qmp/qmp.py | 2 +- scripts/device-crash-test | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) -- 2.14.3 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() 2018-03-12 18:55 [Qemu-devel] [PATCH 0/3] scripts: Python 3 compatibility fixes Eduardo Habkost @ 2018-03-12 18:55 ` Eduardo Habkost 2018-03-12 19:24 ` Daniel P. Berrangé 2018-03-12 23:02 ` Philippe Mathieu-Daudé 2018-03-12 18:55 ` [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending Eduardo Habkost 2018-03-12 18:55 ` [Qemu-devel] [PATCH 3/3] device-crash-test: Use 'python' binary Eduardo Habkost 2 siblings, 2 replies; 10+ messages in thread From: Eduardo Habkost @ 2018-03-12 18:55 UTC (permalink / raw) To: qemu-devel Cc: Lukáš Doktor, Cleber Rosa, Philippe Mathieu-Daudé 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: -- 2.14.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() 2018-03-12 18:55 ` [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() Eduardo Habkost @ 2018-03-12 19:24 ` Daniel P. Berrangé 2018-03-12 23:02 ` Philippe Mathieu-Daudé 1 sibling, 0 replies; 10+ messages in thread From: Daniel P. Berrangé @ 2018-03-12 19:24 UTC (permalink / raw) To: Eduardo Habkost Cc: qemu-devel, Lukáš Doktor, Philippe Mathieu-Daudé, Cleber Rosa 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 -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() 2018-03-12 18:55 ` [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() Eduardo Habkost 2018-03-12 19:24 ` Daniel P. Berrangé @ 2018-03-12 23:02 ` Philippe Mathieu-Daudé 2018-03-13 1:25 ` Eduardo Habkost 1 sibling, 1 reply; 10+ messages in thread From: Philippe Mathieu-Daudé @ 2018-03-12 23:02 UTC (permalink / raw) To: Eduardo Habkost, qemu-devel; +Cc: Lukáš Doktor, Cleber Rosa 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 ;) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() 2018-03-12 23:02 ` Philippe Mathieu-Daudé @ 2018-03-13 1:25 ` Eduardo Habkost 0 siblings, 0 replies; 10+ messages in thread From: Eduardo Habkost @ 2018-03-13 1:25 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: qemu-devel, Lukáš Doktor, Cleber Rosa 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¨). -- Eduardo ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending 2018-03-12 18:55 [Qemu-devel] [PATCH 0/3] scripts: Python 3 compatibility fixes Eduardo Habkost 2018-03-12 18:55 ` [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() Eduardo Habkost @ 2018-03-12 18:55 ` Eduardo Habkost 2018-03-12 19:24 ` Daniel P. Berrangé 2018-03-12 23:03 ` Philippe Mathieu-Daudé 2018-03-12 18:55 ` [Qemu-devel] [PATCH 3/3] device-crash-test: Use 'python' binary Eduardo Habkost 2 siblings, 2 replies; 10+ messages in thread From: Eduardo Habkost @ 2018-03-12 18:55 UTC (permalink / raw) To: qemu-devel; +Cc: Lukáš Doktor, Cleber Rosa On Python 3, json.dumps() return a str object, which can't be sent directly through a socket and must be encoded into a bytes object. Use .encode('utf-8'), which will work on both Python 2 and Python 3. Signed-off-by: Eduardo Habkost <ehabkost@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 07c9632e9e..5c8cf6a056 100644 --- a/scripts/qmp/qmp.py +++ b/scripts/qmp/qmp.py @@ -166,7 +166,7 @@ class QEMUMonitorProtocol(object): """ self.logger.debug(">>> %s", qmp_cmd) try: - self.__sock.sendall(json.dumps(qmp_cmd)) + self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8')) except socket.error as err: if err[0] == errno.EPIPE: return -- 2.14.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending 2018-03-12 18:55 ` [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending Eduardo Habkost @ 2018-03-12 19:24 ` Daniel P. Berrangé 2018-03-12 23:03 ` Philippe Mathieu-Daudé 1 sibling, 0 replies; 10+ messages in thread From: Daniel P. Berrangé @ 2018-03-12 19:24 UTC (permalink / raw) To: Eduardo Habkost; +Cc: qemu-devel, Lukáš Doktor, Cleber Rosa On Mon, Mar 12, 2018 at 03:55:02PM -0300, Eduardo Habkost wrote: > On Python 3, json.dumps() return a str object, which can't be > sent directly through a socket and must be encoded into a bytes > object. Use .encode('utf-8'), which will work on both Python 2 > and Python 3. > > Signed-off-by: Eduardo Habkost <ehabkost@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 07c9632e9e..5c8cf6a056 100644 > --- a/scripts/qmp/qmp.py > +++ b/scripts/qmp/qmp.py > @@ -166,7 +166,7 @@ class QEMUMonitorProtocol(object): > """ > self.logger.debug(">>> %s", qmp_cmd) > try: > - self.__sock.sendall(json.dumps(qmp_cmd)) > + self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8')) > except socket.error as err: > if err[0] == errno.EPIPE: > return Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending 2018-03-12 18:55 ` [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending Eduardo Habkost 2018-03-12 19:24 ` Daniel P. Berrangé @ 2018-03-12 23:03 ` Philippe Mathieu-Daudé 1 sibling, 0 replies; 10+ messages in thread From: Philippe Mathieu-Daudé @ 2018-03-12 23:03 UTC (permalink / raw) To: Eduardo Habkost, qemu-devel; +Cc: Lukáš Doktor, Cleber Rosa On 03/12/2018 07:55 PM, Eduardo Habkost wrote: > On Python 3, json.dumps() return a str object, which can't be > sent directly through a socket and must be encoded into a bytes > object. Use .encode('utf-8'), which will work on both Python 2 > and Python 3. > > Signed-off-by: Eduardo Habkost <ehabkost@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 07c9632e9e..5c8cf6a056 100644 > --- a/scripts/qmp/qmp.py > +++ b/scripts/qmp/qmp.py > @@ -166,7 +166,7 @@ class QEMUMonitorProtocol(object): > """ > self.logger.debug(">>> %s", qmp_cmd) > try: > - self.__sock.sendall(json.dumps(qmp_cmd)) > + self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8')) > except socket.error as err: > if err[0] == errno.EPIPE: > return > http://lists.nongnu.org/archive/html/qemu-devel/2017-12/msg04047.html ;) ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 3/3] device-crash-test: Use 'python' binary 2018-03-12 18:55 [Qemu-devel] [PATCH 0/3] scripts: Python 3 compatibility fixes Eduardo Habkost 2018-03-12 18:55 ` [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() Eduardo Habkost 2018-03-12 18:55 ` [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending Eduardo Habkost @ 2018-03-12 18:55 ` Eduardo Habkost 2018-03-12 19:24 ` Daniel P. Berrangé 2 siblings, 1 reply; 10+ messages in thread From: Eduardo Habkost @ 2018-03-12 18:55 UTC (permalink / raw) To: qemu-devel; +Cc: Lukáš Doktor, Cleber Rosa Now the script works with Python 3, so we can use the 'python' binary provided by the system. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- scripts/device-crash-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/device-crash-test b/scripts/device-crash-test index 36194e4347..7e79a8d885 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python # # Copyright (c) 2017 Red Hat Inc # -- 2.14.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] device-crash-test: Use 'python' binary 2018-03-12 18:55 ` [Qemu-devel] [PATCH 3/3] device-crash-test: Use 'python' binary Eduardo Habkost @ 2018-03-12 19:24 ` Daniel P. Berrangé 0 siblings, 0 replies; 10+ messages in thread From: Daniel P. Berrangé @ 2018-03-12 19:24 UTC (permalink / raw) To: Eduardo Habkost; +Cc: qemu-devel, Lukáš Doktor, Cleber Rosa On Mon, Mar 12, 2018 at 03:55:03PM -0300, Eduardo Habkost wrote: > Now the script works with Python 3, so we can use the 'python' > binary provided by the system. > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > scripts/device-crash-test | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/device-crash-test b/scripts/device-crash-test > index 36194e4347..7e79a8d885 100755 > --- a/scripts/device-crash-test > +++ b/scripts/device-crash-test > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python2.7 > +#!/usr/bin/env python > # > # Copyright (c) 2017 Red Hat Inc > # Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-03-13 1:25 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-03-12 18:55 [Qemu-devel] [PATCH 0/3] scripts: Python 3 compatibility fixes Eduardo Habkost 2018-03-12 18:55 ` [Qemu-devel] [PATCH 1/3] qemu.py: Use items() instead of iteritems() Eduardo Habkost 2018-03-12 19:24 ` Daniel P. Berrangé 2018-03-12 23:02 ` Philippe Mathieu-Daudé 2018-03-13 1:25 ` Eduardo Habkost 2018-03-12 18:55 ` [Qemu-devel] [PATCH 2/3] qmp.py: Encode json data before sending Eduardo Habkost 2018-03-12 19:24 ` Daniel P. Berrangé 2018-03-12 23:03 ` Philippe Mathieu-Daudé 2018-03-12 18:55 ` [Qemu-devel] [PATCH 3/3] device-crash-test: Use 'python' binary Eduardo Habkost 2018-03-12 19:24 ` Daniel P. Berrangé
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.