[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v2] python: add virDomainGetCPUStats python binding API



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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]