mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
On long to the negative long power, let float handle it instead of
raising an error. This was one of the two issues that the VPython folks were particularly problematic for their students. (The other one was integer division...) This implements (my) SF patch #440487.
This commit is contained in:
parent
b82fedc7d8
commit
0ec9abaa2b
1 changed files with 7 additions and 8 deletions
|
@ -1543,14 +1543,13 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
||||||
|
|
||||||
size_b = b->ob_size;
|
size_b = b->ob_size;
|
||||||
if (size_b < 0) {
|
if (size_b < 0) {
|
||||||
if (a->ob_size)
|
/* Return a float. This works because we know that
|
||||||
PyErr_SetString(PyExc_ValueError,
|
this calls float_pow() which converts its
|
||||||
"long integer to a negative power");
|
arguments to double. */
|
||||||
else
|
Py_DECREF(a);
|
||||||
PyErr_SetString(PyExc_ZeroDivisionError,
|
Py_DECREF(b);
|
||||||
"zero to a negative power");
|
Py_DECREF(c);
|
||||||
z = NULL;
|
return PyFloat_Type.tp_as_number->nb_power(v, w, x);
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
z = (PyLongObject *)PyLong_FromLong(1L);
|
z = (PyLongObject *)PyLong_FromLong(1L);
|
||||||
for (i = 0; i < size_b; ++i) {
|
for (i = 0; i < size_b; ++i) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue