aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken/sbkconverter_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'libshiboken/sbkconverter_p.h')
-rw-r--r--libshiboken/sbkconverter_p.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/libshiboken/sbkconverter_p.h b/libshiboken/sbkconverter_p.h
index b1d40ee..766e6fa 100644
--- a/libshiboken/sbkconverter_p.h
+++ b/libshiboken/sbkconverter_p.h
@@ -251,7 +251,17 @@ struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG>
}
static void toCpp(PyObject* pyIn, void* cppOut)
{
- *((unsigned PY_LONG_LONG*)cppOut) = (unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(pyIn);
+ if (PyInt_Check(pyIn)) {
+ long result = (unsigned PY_LONG_LONG) PyInt_AsLong(pyIn);
+ if (result < 0)
+ PyErr_SetObject(PyExc_OverflowError, 0);
+ else
+ *((unsigned PY_LONG_LONG*)cppOut) = (unsigned PY_LONG_LONG) result;
+ } else if (PyLong_Check(pyIn)) {
+ *((unsigned PY_LONG_LONG*)cppOut) = (unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(pyIn);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Invalid type for unsigned long long conversion");
+ }
}
static PythonToCppFunc isConvertible(PyObject* pyIn)
{