Verify heappop argument is a list.

This commit is contained in:
Raymond Hettinger 2003-11-15 12:33:01 +00:00
parent cf0005baf4
commit 236a2443fb
1 changed files with 5 additions and 0 deletions

View File

@ -119,6 +119,11 @@ heappop(PyObject *self, PyObject *heap)
PyObject *lastelt, *returnitem;
int n;
if (!PyList_Check(heap)) {
PyErr_SetString(PyExc_ValueError, "heap argument must be a list");
return NULL;
}
/* # raises appropriate IndexError if heap is empty */
n = PyList_GET_SIZE(heap);
if (n == 0) {