[PATCH python 11/14] override: Conditionalize use of PyString_Check and PyInt_Check

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

 



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

The PyString and PyInt classes are gone in Python 3, so we must
conditionalize their use to be Python 2 only.

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

diff --git a/libvirt-override.c b/libvirt-override.c
index 9a013ca..77c0af2 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -322,7 +322,11 @@ virPyDictToTypedParams(PyObject *dict,
         }
 
         if (type == -1) {
+#if PY_MAJOR_VERSION > 2
+            if (PyUnicode_Check(value)) {
+#else
             if (PyString_Check(value)) {
+#endif
                 type = VIR_TYPED_PARAM_STRING;
             } else if (PyBool_Check(value)) {
                 type = VIR_TYPED_PARAM_BOOLEAN;
@@ -332,11 +336,13 @@ virPyDictToTypedParams(PyObject *dict,
                     type = VIR_TYPED_PARAM_LLONG;
                 else
                     type = VIR_TYPED_PARAM_ULLONG;
+#if PY_MAJOR_VERSION == 2
             } else if (PyInt_Check(value)) {
                 if (PyInt_AS_LONG(value) < 0)
                     type = VIR_TYPED_PARAM_LLONG;
                 else
                     type = VIR_TYPED_PARAM_ULLONG;
+#endif
             } else if (PyFloat_Check(value)) {
                 type = VIR_TYPED_PARAM_DOUBLE;
             }
-- 
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]