Mercurial > cpython-lru_cache-weakref
diff Objects/longobject.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 | 7df300d284c6 |
line wrap: on
line diff
--- a/Objects/longobject.c Mon Sep 03 05:47:38 2001 +0000 +++ b/Objects/longobject.c Mon Sep 03 08:35:41 2001 +0000 @@ -1598,12 +1598,17 @@ size_b = b->ob_size; if (size_b < 0) { + 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. */ - Py_DECREF(a); - Py_DECREF(b); - Py_DECREF(c); return PyFloat_Type.tp_as_number->nb_power(v, w, x); } z = (PyLongObject *)PyLong_FromLong(1L);
