[Python-checkins] cpython: Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError).

victor.stinner python-checkins at python.org
Mon Jul 8 22:36:35 CEST 2013


http://hg.python.org/cpython/rev/68887e177dd4
changeset:   84510:68887e177dd4
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Jul 08 22:20:44 2013 +0200
summary:
  Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError).

files:
  Objects/listobject.c |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Objects/listobject.c b/Objects/listobject.c
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -925,8 +925,10 @@
     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);

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


More information about the Python-checkins mailing list