From: Ezio Melotti Date: Sun, 18 Nov 2012 21:16:02 +0000 (+0200) Subject: #7782: merge with 3.3. X-Git-Tag: v3.4.0a1~1979 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=739e1790f8576543b4058cc60a993be643367c91;p=thirdparty%2FPython%2Fcpython.git #7782: merge with 3.3. --- diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py index b2f3e652325f..43f8e1588bd4 100644 --- a/Lib/test/test_iter.py +++ b/Lib/test/test_iter.py @@ -903,6 +903,21 @@ class TestCase(unittest.TestCase): 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)