summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_iter.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-18 21:15:47 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-18 21:15:47 (GMT)
commit4b26d5507bb7dafb1e5c7c252217ce3f669e7eac (patch)
treed88b64772e20b693d109699b51a1a77c0382a12c /Lib/test/test_iter.py
parent946eb459306d545a9975810021a75d7775358034 (diff)
parent4a1fdcf07d4ee37ec003cd29be6b17e91d5db012 (diff)
downloadcpython-4b26d5507bb7dafb1e5c7c252217ce3f669e7eac.zip
cpython-4b26d5507bb7dafb1e5c7c252217ce3f669e7eac.tar.gz
cpython-4b26d5507bb7dafb1e5c7c252217ce3f669e7eac.tar.bz2
#7782: merge with 3.2.
Diffstat (limited to 'Lib/test/test_iter.py')
-rw-r--r--Lib/test/test_iter.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py
index b2f3e65..43f8e15 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)