summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-03-11 10:16:47 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-03-11 10:16:47 (GMT)
commitb5c204249f56d78b67a3f496abd760365ff6d582 (patch)
tree9639efb534c5593d6785e3dca50aa82e30f55adf /Modules
parent879e96f716a444664f98382e292cb049b1ea7db2 (diff)
downloadcpython-b5c204249f56d78b67a3f496abd760365ff6d582.zip
cpython-b5c204249f56d78b67a3f496abd760365ff6d582.tar.gz
cpython-b5c204249f56d78b67a3f496abd760365ff6d582.tar.bz2
backport tim_one's checkin of
revision 2.28 of cmathmodule.c SF bug 525705: [2.2] underflow raise OverflowException. Another year in the quest to out-guess random C behavior. Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y). The latter is useful for functions with complex results. Two corrections to errno- after-libm-call are attempted: 1. If the platform set errno to ERANGE due to underflow, clear errno. Some unknown subset of libm versions and link options do this. It's allowed by C89, but I never figured anyone would do it. 2. If the platform did not set errno but overflow occurred, force errno to ERANGE. C89 required setting errno to ERANGE, but C99 doesn't. Some unknown subset of libm versions and link options do it the C99 way now. Bugfix candidate, but hold off until some Linux people actually try it, with and without -lieee. I'll send a help plea to Python-Dev.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/cmathmodule.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
index adf76b8..6e79680 100644
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -337,8 +337,7 @@ math_1(PyObject *args, Py_complex (*func)(Py_complex))
PyFPE_START_PROTECT("complex function", return 0)
x = (*func)(x);
PyFPE_END_PROTECT(x)
- Py_SET_ERANGE_IF_OVERFLOW(x.real);
- Py_SET_ERANGE_IF_OVERFLOW(x.imag);
+ Py_ADJUST_ERANGE2(x.real, x.imag);
if (errno != 0)
return math_error();
else