summaryrefslogtreecommitdiffstats
path: root/Modules/mathmodule.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-06-17 21:16:55 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2008-06-17 21:16:55 (GMT)
commitfb1c4b98e9bfd3b5f799b5991081d3e4ea78d0eb (patch)
tree5aee39b4b4cd0ce7843c870f03e89a9ffee63289 /Modules/mathmodule.c
parent21a45e1bea1149a30d986af0e7df67a267621d7f (diff)
downloadcpython-fb1c4b98e9bfd3b5f799b5991081d3e4ea78d0eb.zip
cpython-fb1c4b98e9bfd3b5f799b5991081d3e4ea78d0eb.tar.gz
cpython-fb1c4b98e9bfd3b5f799b5991081d3e4ea78d0eb.tar.bz2
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 32c2400..1066702 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 */