[PATCH RFC 11/32] python/qemu/lib: remove Python2 style super() calls

John Snow posted 32 patches 5 years, 6 months ago
Maintainers: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Fam Zheng <fam@euphon.net>, Eduardo Habkost <ehabkost@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Markus Armbruster <armbru@redhat.com>, Max Reitz <mreitz@redhat.com>, Cleber Rosa <crosa@redhat.com>
[PATCH RFC 11/32] python/qemu/lib: remove Python2 style super() calls
Posted by John Snow 5 years, 6 months ago
Use the Python3 style instead.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/qemu/lib/machine.py |  2 +-
 python/qemu/lib/qtest.py   | 15 +++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/python/qemu/lib/machine.py b/python/qemu/lib/machine.py
index 4b260fa2cb..b2f0412197 100644
--- a/python/qemu/lib/machine.py
+++ b/python/qemu/lib/machine.py
@@ -55,7 +55,7 @@ def __init__(self, reply):
             desc = reply["error"]["desc"]
         except KeyError:
             desc = reply
-        super(MonitorResponseError, self).__init__(desc)
+        super().__init__(desc)
         self.reply = reply
 
 
diff --git a/python/qemu/lib/qtest.py b/python/qemu/lib/qtest.py
index 53d814c064..7943487c2b 100644
--- a/python/qemu/lib/qtest.py
+++ b/python/qemu/lib/qtest.py
@@ -101,29 +101,28 @@ def __init__(self, binary, args=None, name=None, test_dir="/var/tmp",
             name = "qemu-%d" % os.getpid()
         if sock_dir is None:
             sock_dir = test_dir
-        super(QEMUQtestMachine,
-              self).__init__(binary, args, name=name, test_dir=test_dir,
-                             socket_scm_helper=socket_scm_helper,
-                             sock_dir=sock_dir)
+        super().__init__(binary, args, name=name, test_dir=test_dir,
+                         socket_scm_helper=socket_scm_helper,
+                         sock_dir=sock_dir)
         self._qtest = None
         self._qtest_path = os.path.join(sock_dir, name + "-qtest.sock")
 
     def _base_args(self):
-        args = super(QEMUQtestMachine, self)._base_args()
+        args = super()._base_args()
         args.extend(['-qtest', 'unix:path=' + self._qtest_path,
                      '-accel', 'qtest'])
         return args
 
     def _pre_launch(self):
-        super(QEMUQtestMachine, self)._pre_launch()
+        super()._pre_launch()
         self._qtest = QEMUQtestProtocol(self._qtest_path, server=True)
 
     def _post_launch(self):
-        super(QEMUQtestMachine, self)._post_launch()
+        super()._post_launch()
         self._qtest.accept()
 
     def _post_shutdown(self):
-        super(QEMUQtestMachine, self)._post_shutdown()
+        super()._post_shutdown()
         self._remove_if_exists(self._qtest_path)
 
     def qtest(self, cmd):
-- 
2.21.1


Re: [PATCH RFC 11/32] python/qemu/lib: remove Python2 style super() calls
Posted by Philippe Mathieu-Daudé 5 years, 6 months ago
On 5/14/20 7:53 AM, John Snow wrote:
> Use the Python3 style instead.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   python/qemu/lib/machine.py |  2 +-
>   python/qemu/lib/qtest.py   | 15 +++++++--------
>   2 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/python/qemu/lib/machine.py b/python/qemu/lib/machine.py
> index 4b260fa2cb..b2f0412197 100644
> --- a/python/qemu/lib/machine.py
> +++ b/python/qemu/lib/machine.py
> @@ -55,7 +55,7 @@ def __init__(self, reply):
>               desc = reply["error"]["desc"]
>           except KeyError:
>               desc = reply
> -        super(MonitorResponseError, self).__init__(desc)
> +        super().__init__(desc)
>           self.reply = reply
>   
>   
> diff --git a/python/qemu/lib/qtest.py b/python/qemu/lib/qtest.py
> index 53d814c064..7943487c2b 100644
> --- a/python/qemu/lib/qtest.py
> +++ b/python/qemu/lib/qtest.py
> @@ -101,29 +101,28 @@ def __init__(self, binary, args=None, name=None, test_dir="/var/tmp",
>               name = "qemu-%d" % os.getpid()
>           if sock_dir is None:
>               sock_dir = test_dir
> -        super(QEMUQtestMachine,
> -              self).__init__(binary, args, name=name, test_dir=test_dir,
> -                             socket_scm_helper=socket_scm_helper,
> -                             sock_dir=sock_dir)
> +        super().__init__(binary, args, name=name, test_dir=test_dir,
> +                         socket_scm_helper=socket_scm_helper,
> +                         sock_dir=sock_dir)
>           self._qtest = None
>           self._qtest_path = os.path.join(sock_dir, name + "-qtest.sock")
>   
>       def _base_args(self):
> -        args = super(QEMUQtestMachine, self)._base_args()
> +        args = super()._base_args()
>           args.extend(['-qtest', 'unix:path=' + self._qtest_path,
>                        '-accel', 'qtest'])
>           return args
>   
>       def _pre_launch(self):
> -        super(QEMUQtestMachine, self)._pre_launch()
> +        super()._pre_launch()
>           self._qtest = QEMUQtestProtocol(self._qtest_path, server=True)
>   
>       def _post_launch(self):
> -        super(QEMUQtestMachine, self)._post_launch()
> +        super()._post_launch()
>           self._qtest.accept()
>   
>       def _post_shutdown(self):
> -        super(QEMUQtestMachine, self)._post_shutdown()
> +        super()._post_shutdown()
>           self._remove_if_exists(self._qtest_path)
>   
>       def qtest(self, cmd):
> 


Re: [PATCH RFC 11/32] python/qemu/lib: remove Python2 style super() calls
Posted by Philippe Mathieu-Daudé 5 years, 5 months ago
On 5/14/20 7:53 AM, John Snow wrote:
> Use the Python3 style instead.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  python/qemu/lib/machine.py |  2 +-
>  python/qemu/lib/qtest.py   | 15 +++++++--------
>  2 files changed, 8 insertions(+), 9 deletions(-)

Thanks, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next