diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-09-03 08:35:41 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-09-03 08:35:41 (GMT) |
commit | 32f453eaa476c78376cd721d29ba8ab726e400bb (patch) | |
tree | aec8b2e54ec4a0a7cbd66569d3a8531db118f153 /Objects/longobject.c | |
parent | 5d2b77cf31c5a3cbabc74936831480b9caea3a12 (diff) | |
download | cpython-32f453eaa476c78376cd721d29ba8ab726e400bb.zip cpython-32f453eaa476c78376cd721d29ba8ab726e400bb.tar.gz cpython-32f453eaa476c78376cd721d29ba8ab726e400bb.tar.bz2 |
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
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 4209419..4d4a959 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -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); |