Armin Rigo | b4b5a76 | 2006-01-14 10:58:30 +0000 | [diff] [blame] | 1 | |
2 | # http://python.org/sf/1303614 | ||||
3 | |||||
4 | class Strange(object): | ||||
5 | def __hash__(self): | ||||
6 | return hash('hello') | ||||
7 | |||||
8 | def __eq__(self, other): | ||||
9 | x.__dict__ = {} # the old x.__dict__ is deallocated | ||||
10 | return False | ||||
11 | |||||
12 | |||||
13 | class X(object): | ||||
14 | pass | ||||
15 | |||||
16 | if __name__ == '__main__': | ||||
17 | v = 123 | ||||
18 | x = X() | ||||
19 | x.__dict__ = {Strange(): 42, | ||||
20 | 'hello': v+456} | ||||
21 | x.hello # segfault: the above dict is accessed after it's deallocated |