Merged revisions 71860 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71860 | benjamin.peterson | 2009-04-24 19:41:22 -0500 (Fri, 24 Apr 2009) | 1 line

  fix a segfault when setting __class__ in __del__ #5283
........
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 407959d..4558b98 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -2747,6 +2747,16 @@
                     continue
                 cant(cls(), cls2)
 
+        # Issue5283: when __class__ changes in __del__, the wrong
+        # type gets DECREF'd.
+        class O(object):
+            pass
+        class A(object):
+            def __del__(self):
+                self.__class__ = O
+        l = [A() for x in range(100)]
+        del l
+
     def test_set_dict(self):
         # Testing __dict__ assignment...
         class C(object): pass