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:
parent
3e188e508d
commit
5481270c2a
3 changed files with 56 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue