[Python-checkins] cpython: Issue #18408: Fix list.extend(), handle list_resize() failure

victor.stinner python-checkins at python.org
Tue Jul 16 23:09:17 CEST 2013


http://hg.python.org/cpython/rev/395e67f348e7
changeset:   84671:395e67f348e7
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jul 16 21:45:58 2013 +0200
summary:
  Issue #18408: Fix list.extend(), handle list_resize() failure

files:
  Objects/listobject.c |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Objects/listobject.c b/Objects/listobject.c
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -871,8 +871,10 @@
     }
 
     /* Cut back result list if initial guess was too large. */
-    if (Py_SIZE(self) < self->allocated)
-        list_resize(self, Py_SIZE(self));  /* shrinking can't fail */
+    if (Py_SIZE(self) < self->allocated) {
+        if (list_resize(self, Py_SIZE(self)) < 0)
+            goto error;
+    }
 
     Py_DECREF(it);
     Py_RETURN_NONE;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list