Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3813c9e commit 4a1fdcfCopy full SHA for 4a1fdcf
1 file changed
Lib/test/test_iter.py
@@ -876,6 +876,21 @@ def __next__(self):
876
except TypeError:
877
pass
878
879
+ def test_extending_list_with_iterator_does_not_segfault(self):
880
+ # The code to extend a list with an iterator has a fair
881
+ # amount of nontrivial logic in terms of guessing how
882
+ # much memory to allocate in advance, "stealing" refs,
883
+ # and then shrinking at the end. This is a basic smoke
884
+ # test for that scenario.
885
+ def gen():
886
+ for i in range(500):
887
+ yield i
888
+ lst = [0] * 500
889
+ for i in range(240):
890
+ lst.pop(0)
891
+ lst.extend(gen())
892
+ self.assertEqual(len(lst), 760)
893
+
894
895
def test_main():
896
run_unittest(TestCase)
0 commit comments