diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-03-09 04:58:24 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-03-09 04:58:24 (GMT) |
commit | dc5a508761d7260bc863a2f3068723c298336382 (patch) | |
tree | 7a59e85272d1bebdce6c05c0da21d5b5d7f926f4 /Objects/floatobject.c | |
parent | d50e544b9f67738f122d9931eab8b8d71633527a (diff) | |
download | cpython-dc5a508761d7260bc863a2f3068723c298336382.zip cpython-dc5a508761d7260bc863a2f3068723c298336382.tar.gz cpython-dc5a508761d7260bc863a2f3068723c298336382.tar.bz2 |
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 'Objects/floatobject.c')
-rw-r--r-- | Objects/floatobject.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index ec8f719..83987ba 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -577,9 +577,9 @@ float_pow(PyObject *v, PyObject *w, PyObject *z) PyFPE_START_PROTECT("pow", return NULL) ix = pow(iv, iw); PyFPE_END_PROTECT(ix) - Py_SET_ERANGE_IF_OVERFLOW(ix); + Py_ADJUST_ERANGE1(ix); if (errno != 0) { - /* XXX could it be another type of error? */ + assert(errno == ERANGE); PyErr_SetFromErrno(PyExc_OverflowError); return NULL; } |