diff options
author | Alex Martelli <aleaxit@gmail.com> | 2006-08-23 20:42:02 (GMT) |
---|---|---|
committer | Alex Martelli <aleaxit@gmail.com> | 2006-08-23 20:42:02 (GMT) |
commit | 20362a820bd09617a33721191aa966416b03427c (patch) | |
tree | d23425e8b6a7c9d56c9fe9500bf887c5007a14ae /Objects | |
parent | 29bef0bbaae7f670e65c81173b8c1afc148aa248 (diff) | |
download | cpython-20362a820bd09617a33721191aa966416b03427c.zip cpython-20362a820bd09617a33721191aa966416b03427c.tar.gz cpython-20362a820bd09617a33721191aa966416b03427c.tar.bz2 |
x**2 should about equal x*x (including for a float x such that the result is
inf) but didn't; added a test to test_float to verify that, and ignored the
ERANGE value for errno in the pow operation to make the new test pass (with
help from Marilyn Davis at the Google Python Sprint -- thanks!).
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/floatobject.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index fa09084..5aeabd9 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -821,12 +821,12 @@ float_pow(PyObject *v, PyObject *w, PyObject *z) ix = pow(iv, iw); PyFPE_END_PROTECT(ix) Py_ADJUST_ERANGE1(ix); - if (errno != 0) { + /* we need to ignore ERANGE here and just return inf */ + if (errno != 0 && errno != ERANGE) { /* We don't expect any errno value other than ERANGE, but * the range of libm bugs appears unbounded. */ - PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : - PyExc_ValueError); + PyErr_SetFromErrno(PyExc_ValueError); return NULL; } return PyFloat_FromDouble(ix); |