[PATCH v1] dep/QMP: fix pylama errors

Juraj Linkeš juraj.linkes at pantheon.tech
Mon Dec 6 13:29:07 CET 2021


Pylama found the following errors:
dep/QMP/qmp.py:114: [E] E1136 Value 'err' is unsubscriptable [pylint]
dep/QMP/qmp.py:153: [E] E1136 Value 'err' is unsubscriptable [pylint]
dep/QMP/qmp.py:173: [E] E1136 Value 'err' is unsubscriptable [pylint]
- replace the deprecated Exception and fix errno

Signed-off-by: Juraj Linkeš <juraj.linkes at pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
 dep/QMP/qmp.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/dep/QMP/qmp.py b/dep/QMP/qmp.py
index 3fd5f1b2..63d3117d 100755
--- a/dep/QMP/qmp.py
+++ b/dep/QMP/qmp.py
@@ -1,5 +1,5 @@
 # QEMU Monitor Protocol Python class
-# 
+#
 # Copyright (C) 2009, 2010 Red Hat Inc.
 #
 # Authors:
@@ -110,8 +110,8 @@ class QEMUMonitorProtocol:
         """
         try:
             self.__sock.sendall(str.encode(json.dumps(qmp_cmd)))
-        except socket.error as err:
-            if err[0] == errno.EPIPE:
+        except OSError as err:
+            if err.errno == errno.EPIPE:
                 return
             raise socket.error(err)
         return self.__json_read()
@@ -149,8 +149,8 @@ class QEMUMonitorProtocol:
         self.__sock.setblocking(0)
         try:
             self.__json_read()
-        except socket.error as err:
-            if err[0] == errno.EAGAIN:
+        except OSError as err:
+            if err.errno == errno.EAGAIN:
                 # No data available
                 pass
         self.__sock.setblocking(1)
@@ -169,8 +169,8 @@ class QEMUMonitorProtocol:
         self.__sock.setblocking(0)
         try:
             self.__json_read()
-        except socket.error as err:
-            if err[0] == errno.EAGAIN:
+        except OSError as err:
+            if err.errno == errno.EAGAIN:
                 # No data available
                 pass
         self.__sock.setblocking(1)
-- 
2.20.1



More information about the dts mailing list