diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-08 20:20:44 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-08 20:20:44 (GMT) |
commit | b27cd3e5ad9e3da24cdce7f498fa64d2994788a0 (patch) | |
tree | 4151e4007bc1875392ee14f84a682216f2fd92fe /Objects/listobject.c | |
parent | c9b7f51ec203ea5148014741d1fefe1a0faeefa1 (diff) | |
download | cpython-b27cd3e5ad9e3da24cdce7f498fa64d2994788a0.zip cpython-b27cd3e5ad9e3da24cdce7f498fa64d2994788a0.tar.gz cpython-b27cd3e5ad9e3da24cdce7f498fa64d2994788a0.tar.bz2 |
Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError).
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index 0c82cc4..b18ef57 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); |