summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2015-12-02 11:28:31 -0800
committerMark Spruiell <mes@zeroc.com>2015-12-02 11:28:31 -0800
commit7ea494f049785c1adf0ec7693cae7744276e42d2 (patch)
tree889a2cdbf371c155a26b6225e2b0c03d58b840ab /python
parentFix for ICE-6896 - sporadic binding test failure with the Python language map... (diff)
downloadice-7ea494f049785c1adf0ec7693cae7744276e42d2.tar.bz2
ice-7ea494f049785c1adf0ec7693cae7744276e42d2.tar.xz
ice-7ea494f049785c1adf0ec7693cae7744276e42d2.zip
Fixes for ICE-6905 - support NaN/Infinity in scripting languages
Diffstat (limited to 'python')
-rw-r--r--python/modules/IcePy/Types.cpp2
-rw-r--r--python/test/Ice/operations/Twoways.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/python/modules/IcePy/Types.cpp b/python/modules/IcePy/Types.cpp
index ea749bad672..45579378801 100644
--- a/python/modules/IcePy/Types.cpp
+++ b/python/modules/IcePy/Types.cpp
@@ -726,7 +726,7 @@ IcePy::PrimitiveInfo::validate(PyObject* p)
{
// Ensure double does not exceed maximum float value before casting
double val = PyFloat_AsDouble(p);
- return val <= numeric_limits<float>::max() && val >= -numeric_limits<float>::max();
+ return (val <= numeric_limits<float>::max() && val >= -numeric_limits<float>::max()) || !isfinite(val);
}
break;
diff --git a/python/test/Ice/operations/Twoways.py b/python/test/Ice/operations/Twoways.py
index 1299a375d7a..f02109756ed 100644
--- a/python/test/Ice/operations/Twoways.py
+++ b/python/test/Ice/operations/Twoways.py
@@ -141,6 +141,13 @@ def twoways(communicator, p):
r, f, d = p.opFloatDouble(3.402823466E38, 0.0)
r, f, d = p.opFloatDouble(-3.402823466E38, 0.0)
+ for val in ('inf', '-inf'):
+ r, f, d = p.opFloatDouble(float(val), float(val))
+ test(math.isinf(r) and math.isinf(f) and math.isinf(d))
+ for val in ('nan', '-nan'):
+ r, f, d = p.opFloatDouble(float(val), float(val))
+ test(math.isnan(r) and math.isnan(f) and math.isnan(d))
+
try:
r, f, d = p.opFloatDouble(3.402823466E38*2, 0.0)
test(False)