]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError).
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 8 Jul 2013 20:20:44 +0000 (22:20 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 8 Jul 2013 20:20:44 +0000 (22:20 +0200)
Objects/listobject.c

index 0c82cc40ecaced9a8ad7a6594279c52b77810a3c..b18ef5763afee5bf9c0a7e3d2f0f2e6b958e95cc 100644 (file)
@@ -925,8 +925,10 @@ listpop(PyListObject *self, PyObject *args)
     v = self->ob_item[i];
     if (i == Py_SIZE(self) - 1) {
         status = list_resize(self, Py_SIZE(self) - 1);
-        assert(status >= 0);
-        return v; /* and v now owns the reference the list had */
+        if (status >= 0)
+            return v; /* and v now owns the reference the list had */
+        else
+            return NULL;
     }
     Py_INCREF(v);
     status = list_ass_slice(self, i, i+1, (PyObject *)NULL);