Mercurial > cpython-lru_cache-weakref
diff Objects/floatobject.c @ 19666:cf65ebf87560 legacy-trunk
New restriction on pow(x, y, z): If z is not None, x and y must be of
integer types, and y must be >= 0. See discussion at
http://sf.net/tracker/index.php?func=detail&aid=457066&group_id=5470&atid=105470
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Mon, 03 Sep 2001 08:35:41 +0000 |
| parents | c0a44829bcd5 |
| children | b3271297b984 |
line wrap: on
line diff
--- a/Objects/floatobject.c Mon Sep 03 05:47:38 2001 +0000 +++ b/Objects/floatobject.c Mon Sep 03 08:35:41 2001 +0000 @@ -492,11 +492,13 @@ float_pow(PyObject *v, PyObject *w, PyObject *z) { double iv, iw, ix; - /* XXX Doesn't handle overflows if z!=None yet; it may never do so :( - * The z parameter is really only going to be useful for integers and - * long integers. Maybe something clever with logarithms could be done. - * [AMK] - */ + + if ((PyObject *)z != Py_None) { + PyErr_SetString(PyExc_TypeError, + "3rd argument to floating pow() must be None"); + return NULL; + } + CONVERT_TO_DOUBLE(v, iv); CONVERT_TO_DOUBLE(w, iw); @@ -538,16 +540,6 @@ PyErr_SetFromErrno(PyExc_OverflowError); return NULL; } - if ((PyObject *)z != Py_None) { - double iz; - CONVERT_TO_DOUBLE(z, iz); - PyFPE_START_PROTECT("pow", return 0) - ix = fmod(ix, iz); /* XXX To Be Rewritten */ - if (ix != 0 && ((iv < 0 && iz > 0) || (iv > 0 && iz < 0) )) { - ix += iz; - } - PyFPE_END_PROTECT(ix) - } return PyFloat_FromDouble(ix); }
