diff options
author | Sébastien Sablé <sable@users.sourceforge.net> | 2013-03-01 11:37:20 +0100 |
---|---|---|
committer | Hugo Parente Lima <hugo.lima@openbossa.org> | 2013-03-14 18:09:06 +0100 |
commit | 91142c00a45b78d6dafd9e0a472243cff951a507 (patch) | |
tree | 319ceab133bca02af73c73babfcad801ce086500 /libshiboken/conversions.h | |
parent | 00d80865b7ef20440a4c925940c5576bbc8e248b (diff) |
Fix handling of unsigned long long and provide unittests.
Change-Id: I29674a2d758ebf4650e2fe26cdc2e663c0bae5c7
Reviewed-by: Sébastien Sablé <sable@users.sourceforge.net>
Reviewed-by: Hugo Parente Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'libshiboken/conversions.h')
-rw-r--r-- | libshiboken/conversions.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h index b925770c2..6a0429e31 100644 --- a/libshiboken/conversions.h +++ b/libshiboken/conversions.h @@ -435,7 +435,19 @@ struct Converter<unsigned PY_LONG_LONG> } static inline unsigned PY_LONG_LONG toCpp(PyObject* pyobj) { - return (unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(pyobj); + if (PyInt_Check(pyobj)) { + long result = (unsigned PY_LONG_LONG) PyInt_AsLong(pyobj); + if (result < 0) { + PyErr_SetObject(PyExc_OverflowError, 0); + return 0; + } else + return (unsigned PY_LONG_LONG) result; + } else if (PyLong_Check(pyobj)) { + return (unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(pyobj); + } else { + PyErr_SetString(PyExc_TypeError, "Invalid type for unsigned long long conversion"); + return 0; + } } }; |