[Python-checkins] cpython: #7782: merge with 3.3.

ezio.melotti python-checkins at python.org
Sun Nov 18 22:16:21 CET 2012


http://hg.python.org/cpython/rev/d2b98a4c4251
changeset:   80517:d2b98a4c4251
parent:      80511:4def3c26dcf8
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Sun Nov 18 23:16:02 2012 +0200
summary:
  #7782: merge with 3.3.

files:
  Lib/test/test_iter.py |  15 +++++++++++++++
  1 files changed, 15 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py
--- a/Lib/test/test_iter.py
+++ b/Lib/test/test_iter.py
@@ -903,6 +903,21 @@
         except TypeError:
             pass
 
+    def test_extending_list_with_iterator_does_not_segfault(self):
+        # The code to extend a list with an iterator has a fair
+        # amount of nontrivial logic in terms of guessing how
+        # much memory to allocate in advance, "stealing" refs,
+        # and then shrinking at the end.  This is a basic smoke
+        # test for that scenario.
+        def gen():
+            for i in range(500):
+                yield i
+        lst = [0] * 500
+        for i in range(240):
+            lst.pop(0)
+        lst.extend(gen())
+        self.assertEqual(len(lst), 760)
+
 
 def test_main():
     run_unittest(TestCase)

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


More information about the Python-checkins mailing list