[Python-checkins] cpython: Issue #18408: Fix heapq.heappop(), handle PyList_SetSlice() failure

victor.stinner python-checkins at python.org
Wed Jul 17 22:11:50 CEST 2013


http://hg.python.org/cpython/rev/563b27bef79f
changeset:   84691:563b27bef79f
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Jul 17 21:50:21 2013 +0200
summary:
  Issue #18408: Fix heapq.heappop(), handle PyList_SetSlice() failure

files:
  Modules/_heapqmodule.c |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c
--- a/Modules/_heapqmodule.c
+++ b/Modules/_heapqmodule.c
@@ -168,7 +168,10 @@
 
     lastelt = PyList_GET_ITEM(heap, n-1) ;
     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--;
 
     if (!n)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list