]> xenbits.xensource.com Git - libvirt.git/commitdiff
python: Properly report errors if virStreamRecv fails
authorCole Robinson <crobinso@redhat.com>
Tue, 26 Jul 2011 23:25:43 +0000 (19:25 -0400)
committerCole Robinson <crobinso@redhat.com>
Tue, 26 Jul 2011 23:33:36 +0000 (19:33 -0400)
We only want to raise the special value -2. -1 should return None
which tells the bindings to throw an exception.

python/libvirt-override.c

index 70e0238026a140c58f8b93a3a943a486966b5835..bdff0e9ce0c739240d2563935aa2fb54fbf76aee 100644 (file)
@@ -4138,8 +4138,10 @@ libvirt_virStreamRecv(PyObject *self ATTRIBUTE_UNUSED,
     buf[ret > -1 ? ret : 0] = '\0';
     DEBUG("StreamRecv ret=%d strlen=%d\n", ret, (int) strlen(buf));
 
-    if (ret < 0)
+    if (ret == -2)
         return libvirt_intWrap(ret);
+    if (ret < 0)
+        return VIR_PY_NONE;
     return libvirt_charPtrSizeWrap((char *) buf, (Py_ssize_t) ret);
 }