mirror of
https://github.com/python/cpython.git
synced 2025-07-29 22:24:49 +00:00
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!).
This commit is contained in:
parent
29bef0bbaa
commit
20362a820b
2 changed files with 17 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue