Commit b27cd3e5 authored by Victor Stinner's avatar Victor Stinner

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

parent c9b7f51e
...@@ -925,8 +925,10 @@ listpop(PyListObject *self, PyObject *args) ...@@ -925,8 +925,10 @@ listpop(PyListObject *self, PyObject *args)
v = self->ob_item[i]; v = self->ob_item[i];
if (i == Py_SIZE(self) - 1) { if (i == Py_SIZE(self) - 1) {
status = list_resize(self, Py_SIZE(self) - 1); status = list_resize(self, Py_SIZE(self) - 1);
assert(status >= 0); if (status >= 0)
return v; /* and v now owns the reference the list had */ return v; /* and v now owns the reference the list had */
else
return NULL;
} }
Py_INCREF(v); Py_INCREF(v);
status = list_ass_slice(self, i, i+1, (PyObject *)NULL); status = list_ass_slice(self, i, i+1, (PyObject *)NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment