1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-29 19:41:52 +03:00

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>
This commit is contained in:
Philipp Hahn
2020-04-20 11:47:33 +02:00
committed by Daniel Berrange
parent 051a00c212
commit d49e850807

View File

@ -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