Armin Rigo | b4b5a76 | 2006-01-14 10:58:30 +0000 | [diff] [blame] | 1 | |
2 | # http://python.org/sf/1303614 | ||||
3 | |||||
4 | class Y(object): | ||||
5 | pass | ||||
6 | |||||
7 | class type_with_modifiable_dict(Y, type): | ||||
8 | pass | ||||
9 | |||||
10 | class MyClass(object): | ||||
11 | """This class has its __dict__ attribute completely exposed: | ||||
12 | user code can read, reassign and even delete it. | ||||
13 | """ | ||||
14 | __metaclass__ = type_with_modifiable_dict | ||||
15 | |||||
16 | |||||
17 | if __name__ == '__main__': | ||||
18 | del MyClass.__dict__ # if we set tp_dict to NULL, | ||||
19 | print MyClass # doing anything with MyClass segfaults |