mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
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.
This commit is contained in:
parent
4779a0a6fd
commit
c54d19043a
4 changed files with 102 additions and 62 deletions
|
@ -1244,8 +1244,12 @@ long_pow(PyLongObject *a, PyLongObject *b, PyLongObject *c)
|
|||
|
||||
size_b = b->ob_size;
|
||||
if (size_b < 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"long integer to the negative power");
|
||||
if (a->ob_size)
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"long integer to a negative power");
|
||||
else
|
||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
||||
"zero to a negative power");
|
||||
return NULL;
|
||||
}
|
||||
z = (PyLongObject *)PyLong_FromLong(1L);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue