summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-03-08 00:41:11 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-03-08 00:41:11 (GMT)
commit52c424343d625d3e795bd670aaaf542dfa63b7c7 (patch)
tree8744b09cf8766d55a1ba348258e728b9d307613e /Lib/test
parent1ae230aa1a0c7b51839c6d07eaaddfeef71be63b (diff)
downloadcpython-52c424343d625d3e795bd670aaaf542dfa63b7c7.zip
cpython-52c424343d625d3e795bd670aaaf542dfa63b7c7.tar.gz
cpython-52c424343d625d3e795bd670aaaf542dfa63b7c7.tar.bz2
allow cycles throught the __dict__ slot to be cleared (closes #1469629)
Patch from Armin, test from me.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_descr.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 92304b4..4aeb77f 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1,8 +1,10 @@
import builtins
+import gc
import sys
import types
import math
import unittest
+import weakref
from copy import deepcopy
from test import support
@@ -1186,7 +1188,6 @@ order (MRO) for bases """
self.assertEqual(Counted.counter, 0)
# Test lookup leaks [SF bug 572567]
- import gc
if hasattr(gc, 'get_objects'):
class G(object):
def __eq__(self, other):
@@ -4380,7 +4381,6 @@ order (MRO) for bases """
self.assertRaises(AttributeError, getattr, C(), "attr")
self.assertEqual(descr.counter, 4)
- import gc
class EvilGetattribute(object):
# This used to segfault
def __getattr__(self, name):
@@ -4429,6 +4429,21 @@ order (MRO) for bases """
foo = Foo()
str(foo)
+ def test_cycle_through_dict(self):
+ # See bug #1469629
+ class X(dict):
+ def __init__(self):
+ dict.__init__(self)
+ self.__dict__ = self
+ x = X()
+ x.attr = 42
+ wr = weakref.ref(x)
+ del x
+ support.gc_collect()
+ self.assertIsNone(wr())
+ for o in gc.get_objects():
+ self.assertIsNot(type(o), X)
+
class DictProxyTests(unittest.TestCase):
def setUp(self):
class C(object):