summaryrefslogtreecommitdiffstats
path: root/Modules/mathmodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-06-17 22:39:26 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-06-17 22:39:26 (GMT)
commitc2c5e00d9da5cfb01e2c84043669de3d0c6fe35b (patch)
tree59b0b421e491f8634dbac3a98ce2566fde7e1c37 /Modules/mathmodule.c
parentf9f2982feeee97b15fd3706122e250bfeeb97153 (diff)
downloadcpython-c2c5e00d9da5cfb01e2c84043669de3d0c6fe35b.zip
cpython-c2c5e00d9da5cfb01e2c84043669de3d0c6fe35b.tar.gz
cpython-c2c5e00d9da5cfb01e2c84043669de3d0c6fe35b.tar.bz2
Merged revisions 64349 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r64349 | mark.dickinson | 2008-06-17 16:16:55 -0500 (Tue, 17 Jun 2008) | 4 lines Issue 3118: make test_math pass on Ubuntu/ia64. exp(-745.0) was raising OverflowError incorrectly on this platform, presumably as a result of the libm setting errno = ERANGE for this call. ........
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r--Modules/mathmodule.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index fa607e3..4c820c5 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -82,12 +82,17 @@ is_error(double x)
* should return a zero on underflow, and +- HUGE_VAL on
* overflow, so testing the result for zero suffices to
* distinguish the cases).
+ *
+ * On some platforms (Ubuntu/ia64) it seems that errno can be
+ * set to ERANGE for subnormal results that do *not* underflow
+ * to zero. So to be safe, we'll ignore ERANGE whenever the
+ * function result is less than one in absolute value.
*/
- if (x)
+ if (fabs(x) < 1.0)
+ result = 0;
+ else
PyErr_SetString(PyExc_OverflowError,
"math range error");
- else
- result = 0;
}
else
/* Unexpected math error */