blob: 6e403eb344c1845823a66edb2a7f3793b6a37118 [file] [log] [blame]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001"""
2_PyType_Lookup() returns a borrowed reference.
3This attacks PyObject_GenericSetAttr().
4
5NB. on my machine this crashes in 2.5 debug but not release.
6"""
7
8class A(object):
9 pass
10
11class B(object):
12 def __del__(self):
Guido van Rossumbe19ed72007-02-09 05:37:30 +000013 print("hi")
Thomas Wouters0e3f5912006-08-11 14:57:12 +000014 del C.d
15
16class D(object):
17 def __set__(self, obj, value):
18 self.hello = 42
19
20class C(object):
21 d = D()
22
23 def g():
24 pass
25
26
27c = C()
28a = A()
29a.cycle = a
30a.other = B()
31
32lst = [None] * 1000000
33i = 0
34del a
35while 1:
Christian Heimesff737952007-11-27 10:40:20 +000036 c.d = 42 # segfaults in PyMethod_New(__func__=D.__set__, __self__=d)
Thomas Wouters0e3f5912006-08-11 14:57:12 +000037 lst[i] = c.g # consume the free list of instancemethod objects
38 i += 1