From 32f453eaa476c78376cd721d29ba8ab726e400bb Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Mon, 3 Sep 2001 08:35:41 +0000 Subject: 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 --- Objects/intobject.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Objects/intobject.c') diff --git a/Objects/intobject.c b/Objects/intobject.c index 108e658755..eaf869f7bc 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -575,6 +575,11 @@ int_pow(PyIntObject *v, PyIntObject *w, PyIntObject *z) CONVERT_TO_LONG(v, iv); CONVERT_TO_LONG(w, iw); if (iw < 0) { + if ((PyObject *)z != 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. */ -- cgit v1.2.1