Verify heappop argument is a list.
diff --git a/Modules/heapqmodule.c b/Modules/heapqmodule.c
index 8a6a4f5..629f516 100644
--- a/Modules/heapqmodule.c
+++ b/Modules/heapqmodule.c
@@ -119,6 +119,11 @@
 	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) {