diff options
Diffstat (limited to 'typewrappers.c')
-rw-r--r-- | typewrappers.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/typewrappers.c b/typewrappers.c index c525e59..76400a6 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -200,12 +200,16 @@ libvirt_ulongUnwrap(PyObject *obj, unsigned long *val) int libvirt_longlongUnwrap(PyObject *obj, long long *val) { - long long llong_val; + long long llong_val = -1; /* If obj is of PyInt_Type, PyLong_AsLongLong * will call PyInt_AsLong() to handle it automatically. */ - llong_val = PyLong_AsLongLong(obj); + if (PyInt_Check(obj) || PyLong_Check(obj)) + llong_val = PyLong_AsLongLong(obj); + else + PyErr_SetString(PyExc_TypeError, "an integer is required"); + if ((llong_val == -1) && PyErr_Occurred()) return -1; |