Mercurial > cpython-lru_cache-weakref
diff Objects/intobject.c @ 15041:7eefde90ec0e legacy-trunk
SF bug 115831 and Ping's SF patch 101751, 0.0**-2.0 returns inf rather than
raise ValueError. Checked in the patch as far as it went, but also changed
all of ints, longs and floats to raise ZeroDivisionError instead when raising
0 to a negative number. This is what 754-inspired stds require, as the "true
result" is an infinity obtained from finite operands, i.e. it's a singularity.
Also changed float pow to not be so timid about using its square-and-multiply
algorithm. Note that what math.pow does is unrelated to what builtin pow
does, and will still vary by platform.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Fri, 06 Oct 2000 00:36:09 +0000 |
| parents | fb7ac8a40a97 |
| children | e510c4cc5737 8aa947e1eee8 |
line wrap: on
line diff
--- a/Objects/intobject.c Thu Oct 05 22:10:33 2000 +0000 +++ b/Objects/intobject.c Fri Oct 06 00:36:09 2000 +0000 @@ -483,8 +483,12 @@ iv = v->ob_ival; iw = w->ob_ival; if (iw < 0) { - PyErr_SetString(PyExc_ValueError, - "integer to the negative power"); + if (iv) + PyErr_SetString(PyExc_ValueError, + "integer to a negative power"); + else + PyErr_SetString(PyExc_ZeroDivisionError, + "0 to a negative power"); return NULL; } if ((PyObject *)z != Py_None) {
