summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Objects/listobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 5bc4577..6651966 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -739,6 +739,11 @@ listpop(PyListObject *self, PyObject *args)
return NULL;
}
v = self->ob_item[i];
+ if (i == self->ob_size - 1) {
+ if (list_resize(self, self->ob_size - 1) == -1)
+ return NULL;
+ return v;
+ }
Py_INCREF(v);
if (list_ass_slice(self, i, i+1, (PyObject *)NULL) != 0) {
Py_DECREF(v);