blob: 081dcbc2696ab0b894d9bd1ca91326cd02678b62 [file] [log] [blame]
Armin Rigodcde4942008-08-29 21:21:52 +00001# Calls to PyIter_Next, or direct calls to tp_iternext, on an object
2# which might no longer be an iterable because its 'next' method was
3# removed. These are all variants of Issue3720.
4
5"""
6Run this script with an argument between 1 and <N> to test for
7different crashes.
8"""
9N = 8
10
11import sys
12
13class Foo(object):
14 def __iter__(self):
15 return self
16 def next(self):
17 del Foo.next
18 return (1, 2)
19
20def case1():
21 list(enumerate(Foo()))
22
23def case2():
24 x, y = Foo()
25
26def case3():
27 filter(None, Foo())
28
29def case4():
30 map(None, Foo(), Foo())
31
32def case5():
33 max(Foo())
34
35def case6():
36 sum(Foo(), ())
37
38def case7():
39 dict(Foo())
40
41def case8():
42 sys.stdout.writelines(Foo())
43
44# etc...
45
46
47if __name__ == '__main__':
48 if len(sys.argv) < 2:
49 print __doc__.replace('<N>', str(N))
50 else:
51 n = int(sys.argv[1])
52 func = globals()['case%d' % n]
53 func()