mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
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
This commit is contained in:
parent
5d2b77cf31
commit
32f453eaa4
9 changed files with 79 additions and 49 deletions
|
@ -1598,12 +1598,17 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
|
||||
size_b = b->ob_size;
|
||||
if (size_b < 0) {
|
||||
/* Return a float. This works because we know that
|
||||
this calls float_pow() which converts its
|
||||
arguments to double. */
|
||||
Py_DECREF(a);
|
||||
Py_DECREF(b);
|
||||
Py_DECREF(c);
|
||||
if (x != Py_None) {
|
||||
PyErr_SetString(PyExc_TypeError, "integer pow() arg "
|
||||
"3 must not be specified when arg 2 is < 0");
|
||||
return NULL;
|
||||
}
|
||||
/* Return a float. This works because we know that
|
||||
this calls float_pow() which converts its
|
||||
arguments to double. */
|
||||
return PyFloat_Type.tp_as_number->nb_power(v, w, x);
|
||||
}
|
||||
z = (PyLongObject *)PyLong_FromLong(1L);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue