Skip to content

Commit d49e850

Browse files
pmhahnberrange
authored andcommitted
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 <[email protected]>
1 parent 051a00c commit d49e850

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libvirt-override-virStream.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def holeHandler(stream, # virStream instance
200200
if got == -2:
201201
raise libvirtError("cannot use sparseRecvAll with "
202202
"nonblocking stream")
203-
if got == -3:
203+
elif got == -3:
204204
length = self.recvHole()
205205
if length is None:
206206
self.abort()
@@ -210,6 +210,10 @@ def holeHandler(stream, # virStream instance
210210
self.abort()
211211
raise RuntimeError("holeHandler handler returned %d" % ret)
212212
continue
213+
elif isinstance(got, int):
214+
raise ValueError(got)
215+
elif not isinstance(got, bytes):
216+
raise TypeError(type(got))
213217

214218
if len(got) == 0:
215219
break

0 commit comments

Comments
 (0)