(original) (raw)

changeset: 84510:68887e177dd4 user: Victor Stinner victor.stinner@gmail.com date: Mon Jul 08 22:20:44 2013 +0200 files: Objects/listobject.c description: Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError). diff -r ba766323b53a -r 68887e177dd4 Objects/listobject.c --- a/Objects/listobject.c Mon Jul 08 22:19:20 2013 +0200 +++ b/Objects/listobject.c Mon Jul 08 22:20:44 2013 +0200 @@ -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); /victor.stinner@gmail.com