On 03/27/2012 07:03 AM, Eric Blake wrote:

+int
+libvirt_boolUnwrap(PyObject *obj, bool *val)
+{
+    int ret = -1;
+
+    /* We only accept PyInt_Type, PyLong_Type and PyBool_Type
+     * as the boolean representation.
Why?

+     */
+    if (PyInt_Check(obj) ||
+        PyLong_Check(obj) || PyBool_Check(obj)) {
+        ret = PyObject_IsTrue(obj);
Why not blindly use PyObject_IsTrue(obj), and accept _all_ objects that
can be converted to python truth values, rather than forcing things to
be PyInt, PyBool, or PyLong?

        If we don't check here, these APIs which use libvirt_boolUnwrap
   will not have any checking for its type of arguments in bool wise.
   The upper python code could pass a null list or dictionary as a False.
Maybe a little bit loose use here. but It's fine to blindly use it actually.

    Guannan Ren

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to