[libvirt] [libvirt-python PATCH] Add a type check for time in libvirt_virDomainSetTime

Luyao Huang lhuang at redhat.com
Mon Oct 20 09:43:21 UTC 2014


When pass a number or other things to setTime,no error output,but set time to 0.
Add a type check and give a clear error messages:

TypeError: time must be dict

Signed-off-by: Luyao Huang <lhuang at redhat.com>
---
 libvirt-override.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libvirt-override.c b/libvirt-override.c
index 9ba87eb..05552a7 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7795,6 +7795,11 @@ libvirt_virDomainSetTime(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
         return NULL;
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 
+    if (!PyDict_Check(py_dict)) {
+        PyErr_Format(PyExc_TypeError, "time must be dict");
+        return NULL;
+    }
+
     py_dict_size = PyDict_Size(py_dict);
 
     if (py_dict_size == 2) {
-- 
1.8.3.1




More information about the libvir-list mailing list