summaryrefslogtreecommitdiff
path: root/libvirt-override-virStream.py
diff options
context:
space:
mode:
authorPhilipp Hahn <hahn@univention.de>2020-04-20 11:47:33 +0200
committerDaniel Berrange <berrange@redhat.com>2020-08-18 09:48:25 +0000
commitd49e85080794e8d8dcf99cda717c969d6a519d71 (patch)
tree66f821984ccd0573bddd09157861aa9f1fac84fd /libvirt-override-virStream.py
parent051a00c212b8191ba44f97339b30af3f8ff54f59 (diff)
downloadlibvirt-python-d49e85080794e8d8dcf99cda717c969d6a519d71.tar.gz
override: Catch type error
handler() should either return bytes or -2 or -3. Explicitly raise ValueError or TypeError to silence mypy. Signed-off-by: Philipp Hahn <hahn@univention.de>
Diffstat (limited to 'libvirt-override-virStream.py')
-rw-r--r--libvirt-override-virStream.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py
index 4aa6f54..722784b 100644
--- a/libvirt-override-virStream.py
+++ b/libvirt-override-virStream.py
@@ -200,7 +200,7 @@
if got == -2:
raise libvirtError("cannot use sparseRecvAll with "
"nonblocking stream")
- if got == -3:
+ elif got == -3:
length = self.recvHole()
if length is None:
self.abort()
@@ -210,6 +210,10 @@
self.abort()
raise RuntimeError("holeHandler handler returned %d" % ret)
continue
+ elif isinstance(got, int):
+ raise ValueError(got)
+ elif not isinstance(got, bytes):
+ raise TypeError(type(got))
if len(got) == 0:
break