Check in some documentation tweaks for PEP 3141, add some tests, and implement

the promotion to complex on pow(negative, fraction).
This commit is contained in:
Jeffrey Yasskin 2007-09-07 15:15:49 +00:00
parent aaaef110dc
commit 3404b3ce2a
5 changed files with 68 additions and 33 deletions

View file

@ -680,9 +680,10 @@ float_pow(PyObject *v, PyObject *w, PyObject *z)
* bugs so we have to figure it out ourselves.
*/
if (iw != floor(iw)) {
PyErr_SetString(PyExc_ValueError, "negative number "
"cannot be raised to a fractional power");
return NULL;
/* Negative numbers raised to fractional powers
* become complex.
*/
return PyComplex_Type.tp_as_number->nb_power(v, w, z);
}
/* iw is an exact integer, albeit perhaps a very large one.
* -1 raised to an exact integer should never be exceptional.