Skip to content

Commit c2c5e00

Browse files
committed
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. ........
1 parent f9f2982 commit c2c5e00

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Modules/mathmodule.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ is_error(double x)
8282
* should return a zero on underflow, and +- HUGE_VAL on
8383
* overflow, so testing the result for zero suffices to
8484
* distinguish the cases).
85+
*
86+
* On some platforms (Ubuntu/ia64) it seems that errno can be
87+
* set to ERANGE for subnormal results that do *not* underflow
88+
* to zero. So to be safe, we'll ignore ERANGE whenever the
89+
* function result is less than one in absolute value.
8590
*/
86-
if (x)
91+
if (fabs(x) < 1.0)
92+
result = 0;
93+
else
8794
PyErr_SetString(PyExc_OverflowError,
8895
"math range error");
89-
else
90-
result = 0;
9196
}
9297
else
9398
/* Unexpected math error */

0 commit comments

Comments
 (0)