[PATCH python 08/14] override: Replace PyInt_AsLong with helper

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Replace use of the PyInt_AsLong libvirt_intUnwrap helper.
This isolates the need for Python3 specific code in one
place

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 libvirt-override.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libvirt-override.c b/libvirt-override.c
index 3334c3f..9a013ca 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -5177,10 +5177,8 @@ libvirt_virEventAddHandleFunc  (int fd,
     if (!result) {
         PyErr_Print();
         PyErr_Clear();
-    } else if (!PyInt_Check(result)) {
-        DEBUG("%s: %s should return an int\n", __FUNCTION__, NAME(addHandle));
     } else {
-        retval = (int)PyInt_AsLong(result);
+        libvirt_intUnwrap(result, &retval);
     }
 
     Py_XDECREF(result);
@@ -5304,10 +5302,8 @@ libvirt_virEventAddTimeoutFunc(int timeout,
     if (!result) {
         PyErr_Print();
         PyErr_Clear();
-    } else if (!PyInt_Check(result)) {
-        DEBUG("%s: %s should return an int\n", __FUNCTION__, NAME(addTimeout));
     } else {
-        retval = (int)PyInt_AsLong(result);
+        libvirt_intUnwrap(result, &retval);
     }
 
     Py_XDECREF(result);
@@ -6825,7 +6821,7 @@ libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
     }
 
     for (i = 0; i < nkeycodes; i++) {
-        keycodes[i] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list, i));
+        libvirt_uintUnwrap(PyList_GetItem(pyobj_list, i), &(keycodes[i]));
     }
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
-- 
1.8.3.1

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]