Issue #18408: Fix heapq.heappop(), handle PyList_SetSlice() failure

This commit is contained in:
Victor Stinner 2013-07-17 21:50:21 +02:00
parent 2ff51b83b8
commit 764a46d2ed
1 changed files with 4 additions and 1 deletions

View File

@ -168,7 +168,10 @@ heappop(PyObject *self, PyObject *heap)
lastelt = PyList_GET_ITEM(heap, n-1) ; lastelt = PyList_GET_ITEM(heap, n-1) ;
Py_INCREF(lastelt); Py_INCREF(lastelt);
PyList_SetSlice(heap, n-1, n, NULL); if (PyList_SetSlice(heap, n-1, n, NULL) < 0) {
Py_DECREF(lastelt);
return NULL;
}
n--; n--;
if (!n) if (!n)