[Python-checkins] r64349 - python/trunk/Modules/mathmodule.c
mark.dickinson
python-checkins at python.org
Tue Jun 17 23:16:55 CEST 2008
Author: mark.dickinson
Date: Tue Jun 17 23:16:55 2008
New Revision: 64349
Log:
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.
Modified:
python/trunk/Modules/mathmodule.c
Modified: python/trunk/Modules/mathmodule.c
==============================================================================
--- python/trunk/Modules/mathmodule.c (original)
+++ python/trunk/Modules/mathmodule.c Tue Jun 17 23:16:55 2008
@@ -82,12 +82,17 @@
* 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 */
More information about the Python-checkins
mailing list