summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-11-15 12:40:28 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-11-15 12:40:28 (GMT)
commit6dab05231d91fe8260e8f68ca898bd952e6e8008 (patch)
tree9e4e54e70b138b7edf574a68a590abe617acaa91
parent236a2443fbe32577bc4b5b9a1b58aa93f9d91de0 (diff)
downloadcpython-6dab05231d91fe8260e8f68ca898bd952e6e8008.zip
cpython-6dab05231d91fe8260e8f68ca898bd952e6e8008.tar.gz
cpython-6dab05231d91fe8260e8f68ca898bd952e6e8008.tar.bz2
Change ValueErrors to TypeErrors and add PyList_Check() assertions.
-rw-r--r--Modules/heapqmodule.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Modules/heapqmodule.c b/Modules/heapqmodule.c
index 629f516..8e724e6 100644
--- a/Modules/heapqmodule.c
+++ b/Modules/heapqmodule.c
@@ -14,6 +14,7 @@ _siftdown(PyListObject *heap, int startpos, int pos)
PyObject *newitem, *parent;
int cmp, parentpos;
+ assert(PyList_Check(heap));
if (pos >= PyList_GET_SIZE(heap)) {
PyErr_SetString(PyExc_IndexError, "index out of range");
return -1;
@@ -48,6 +49,7 @@ _siftup(PyListObject *heap, int pos)
int cmp;
PyObject *newitem, *tmp;
+ assert(PyList_Check(heap));
endpos = PyList_GET_SIZE(heap);
startpos = pos;
if (pos >= endpos) {
@@ -97,7 +99,7 @@ heappush(PyObject *self, PyObject *args)
return NULL;
if (!PyList_Check(heap)) {
- PyErr_SetString(PyExc_ValueError, "heap argument must be a list");
+ PyErr_SetString(PyExc_TypeError, "heap argument must be a list");
return NULL;
}
@@ -120,7 +122,7 @@ heappop(PyObject *self, PyObject *heap)
int n;
if (!PyList_Check(heap)) {
- PyErr_SetString(PyExc_ValueError, "heap argument must be a list");
+ PyErr_SetString(PyExc_TypeError, "heap argument must be a list");
return NULL;
}
@@ -159,7 +161,7 @@ heapreplace(PyObject *self, PyObject *args)
return NULL;
if (!PyList_Check(heap)) {
- PyErr_SetString(PyExc_ValueError, "heap argument must be a list");
+ PyErr_SetString(PyExc_TypeError, "heap argument must be a list");
return NULL;
}
@@ -192,7 +194,7 @@ heapify(PyObject *self, PyObject *heap)
int i, n;
if (!PyList_Check(heap)) {
- PyErr_SetString(PyExc_ValueError, "heap argument must be a list");
+ PyErr_SetString(PyExc_TypeError, "heap argument must be a list");
return NULL;
}