Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError).

This commit is contained in:
Victor Stinner 2013-07-08 22:20:44 +02:00
parent c9b7f51ec2
commit b27cd3e5ad
1 changed files with 4 additions and 2 deletions

View 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);