summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-05 06:24:58 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-05 06:24:58 (GMT)
commit4c483c4d8eac8603ff299adbd373e4f14da61ff9 (patch)
tree46def41f169f5e0c2faebdc7e79197cb37a5e3ad /Objects/longobject.c
parentd893fd68bd8a7be8e0ceb17e3b9ea810de5820e0 (diff)
downloadcpython-4c483c4d8eac8603ff299adbd373e4f14da61ff9.zip
cpython-4c483c4d8eac8603ff299adbd373e4f14da61ff9.tar.gz
cpython-4c483c4d8eac8603ff299adbd373e4f14da61ff9.tar.bz2
Make the error msgs in our pow() implementations consistent.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 91e0b66..e9e408d 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -1685,15 +1685,22 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
-
+
+ if (c != Py_None && ((PyLongObject *)c)->ob_size == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "pow() 3rd argument cannot be 0");
+ z = NULL;
+ goto error;
+ }
+
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");
+ PyErr_SetString(PyExc_TypeError, "pow() 2nd argument "
+ "cannot be negative when 3rd argument specified");
return NULL;
}
/* Return a float. This works because we know that