cpython/Lib/test/crashers/modify_dict_attr.py
Guido van Rossum 52cc1d838f Implement PEP 3115 -- new metaclass syntax and semantics.
The compiler package hasn't been updated yet; test_compiler.py fails.
Otherwise all tests seem to be passing now.  There are no occurrences
of __metaclass__ left in the standard library.
Docs have not been updated.
2007-03-18 15:41:51 +00:00

18 lines
449 B
Python

# http://python.org/sf/1303614
class Y(object):
pass
class type_with_modifiable_dict(Y, type):
pass
class MyClass(object, metaclass=type_with_modifiable_dict):
"""This class has its __dict__ attribute completely exposed:
user code can read, reassign and even delete it.
"""
if __name__ == '__main__':
del MyClass.__dict__ # if we set tp_dict to NULL,
print(MyClass) # doing anything with MyClass segfaults