On 03/21/2012 08:07 PM, Eric Blake wrote:
Maybe we need a wrapper:

int libvirt_boolUnwrap(PyObject *obj, bool *value) {
     int ret = PyObject_IsTrue(obj);
     if (ret<  0)
         return ret;
     *value = ret>  0;
     return 0;
}

and then callers become:

     if (libvirt_boolUnwrap(value,&temp->value.b)<  0)
         goto cleanup;


The libvirt_boolUnwrap is okay to be flexible like this, we still need the caller to check whether or not the value given from user python code is boolean argument, we need to do the data type checking in python C API
   before invoking the wrapper.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to