Fix Python 3 inconsistency handling -ve numbers for unsigned C types.

An OverFlow error is now consistently thrown instead of a TypeError.

Fixes primitive_types testcase for Python 3
This commit is contained in:
William S Fulton 2013-05-25 10:36:14 +01:00
commit 5481270c2a
3 changed files with 56 additions and 3 deletions

View file

@ -127,6 +127,18 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
return SWIG_OK;
} else {
PyErr_Clear();
%#if PY_VERSION_HEX >= 0x03000000
{
long v = PyLong_AsLong(obj);
if (!PyErr_Occurred()) {
if (v < 0) {
return SWIG_OverflowError;
}
} else {
PyErr_Clear();
}
}
%#endif
}
}
%#ifdef SWIG_PYTHON_CAST_MODE