diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2013-05-25 10:36:14 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2013-05-25 10:36:14 +0100 |
commit | 5481270c2a53add0cf9f7a01044a25a6b3013aaf (patch) | |
tree | 8b15da3d9d7a8652b755e9ac7f46b490c29fc0b2 /Lib | |
parent | 3e188e508d877e9c459a4fa09425456c17d7cf97 (diff) | |
download | swig-5481270c2a53add0cf9f7a01044a25a6b3013aaf.tar.gz |
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
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/python/pyprimtypes.swg | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index 3fbd86a21..66ff104a6 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -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 |