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
|
|
@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 2.0.10 (in progress)
|
Version 2.0.10 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2013-05-25: wsfulton
|
||||||
|
[Python] Fix Python 3 inconsistency when negative numbers are passed
|
||||||
|
where a parameter expects an unsigned C type. An OverFlow error is
|
||||||
|
now consistently thrown instead of a TypeError.
|
||||||
|
|
||||||
2013-05-25: Artem Serebriyskiy
|
2013-05-25: Artem Serebriyskiy
|
||||||
SVN Patch ticket #338 - fixes to %attribute macros for template usage
|
SVN Patch ticket #338 - fixes to %attribute macros for template usage
|
||||||
with %arg.
|
with %arg.
|
||||||
|
|
|
||||||
|
|
@ -279,6 +279,18 @@ except TypeError:
|
||||||
if error:
|
if error:
|
||||||
raise RuntimeError, "bad char typemap"
|
raise RuntimeError, "bad char typemap"
|
||||||
|
|
||||||
|
try:
|
||||||
|
error = 0
|
||||||
|
a = t.var_ushort
|
||||||
|
t.var_ushort = -1
|
||||||
|
error = 1
|
||||||
|
except OverflowError:
|
||||||
|
if a != t.var_ushort:
|
||||||
|
error = 1
|
||||||
|
pass
|
||||||
|
if error:
|
||||||
|
raise RuntimeError, "bad ushort typemap"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
error = 0
|
error = 0
|
||||||
a = t.var_uint
|
a = t.var_uint
|
||||||
|
|
@ -291,6 +303,30 @@ except OverflowError:
|
||||||
if error:
|
if error:
|
||||||
raise RuntimeError, "bad uint typemap"
|
raise RuntimeError, "bad uint typemap"
|
||||||
|
|
||||||
|
try:
|
||||||
|
error = 0
|
||||||
|
a = t.var_sizet
|
||||||
|
t.var_sizet = -1
|
||||||
|
error = 1
|
||||||
|
except OverflowError:
|
||||||
|
if a != t.var_sizet:
|
||||||
|
error = 1
|
||||||
|
pass
|
||||||
|
if error:
|
||||||
|
raise RuntimeError, "bad sizet typemap"
|
||||||
|
|
||||||
|
try:
|
||||||
|
error = 0
|
||||||
|
a = t.var_ulong
|
||||||
|
t.var_ulong = -1
|
||||||
|
error = 1
|
||||||
|
except OverflowError:
|
||||||
|
if a != t.var_ulong:
|
||||||
|
error = 1
|
||||||
|
pass
|
||||||
|
if error:
|
||||||
|
raise RuntimeError, "bad ulong typemap"
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,18 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
} else {
|
} else {
|
||||||
PyErr_Clear();
|
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
|
%#ifdef SWIG_PYTHON_CAST_MODE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue