[Python-checkins] r54016 - python/trunk/Lib/test/crashers/modify_dict_attr.py

armin.rigo python-checkins at python.org
Wed Feb 28 10:25:31 CET 2007


Author: armin.rigo
Date: Wed Feb 28 10:25:29 2007
New Revision: 54016

Added:
   python/trunk/Lib/test/crashers/modify_dict_attr.py
      - copied, changed from r53996, python/trunk/Lib/test/crashers/modify_dict_attr.py
Log:
Modify the segfaulting example to show why r53997 is not a solution to
it.


Copied: python/trunk/Lib/test/crashers/modify_dict_attr.py (from r53996, python/trunk/Lib/test/crashers/modify_dict_attr.py)
==============================================================================
--- python/trunk/Lib/test/crashers/modify_dict_attr.py	(original)
+++ python/trunk/Lib/test/crashers/modify_dict_attr.py	Wed Feb 28 10:25:29 2007
@@ -4,16 +4,17 @@
 class Y(object):
     pass
 
-class type_with_modifiable_dict(Y, type):
+class type_with_modifiable_dict(type, Y):
     pass
 
 class MyClass(object):
-    """This class has its __dict__ attribute completely exposed:
-    user code can read, reassign and even delete it.
+    """This class has its __dict__ attribute indirectly
+    exposed via the __dict__ getter/setter of Y.
     """
     __metaclass__ = type_with_modifiable_dict
 
 
 if __name__ == '__main__':
-    del MyClass.__dict__  # if we set tp_dict to NULL,
+    dictattr = Y.__dict__['__dict__']
+    dictattr.__delete__(MyClass)  # if we set tp_dict to NULL,
     print MyClass         # doing anything with MyClass segfaults


More information about the Python-checkins mailing list