From: Victor Stinner Date: Mon, 8 Jul 2013 20:20:44 +0000 (+0200) Subject: Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError). X-Git-Tag: v3.4.0a1~286 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b27cd3e5ad9e3da24cdce7f498fa64d2994788a0;p=python Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError). --- diff --git a/Objects/listobject.c b/Objects/listobject.c index 0c82cc40ec..b18ef5763a 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -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);