summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-01-19 12:46:25 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-01-19 12:46:25 (GMT)
commitd205d0145c8f5a37d0a46261eb0193e27b5b0ad8 (patch)
tree9875b22539719a974e8cbff40300623ae01bd18a /Lib
parente914cd1308103de3f14cecbecc0f9aa46c8be074 (diff)
downloadcpython-d205d0145c8f5a37d0a46261eb0193e27b5b0ad8.zip
cpython-d205d0145c8f5a37d0a46261eb0193e27b5b0ad8.tar.gz
cpython-d205d0145c8f5a37d0a46261eb0193e27b5b0ad8.tar.bz2
Issue #25935: Garbage collector now breaks reference loops with OrderedDict.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_ordered_dict.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_ordered_dict.py b/Lib/test/test_ordered_dict.py
index 9d6c6ff..8ab0a9f 100644
--- a/Lib/test/test_ordered_dict.py
+++ b/Lib/test/test_ordered_dict.py
@@ -1,10 +1,12 @@
import contextlib
import copy
+import gc
import pickle
from random import randrange, shuffle
import struct
import sys
import unittest
+import weakref
from collections.abc import MutableMapping
from test import mapping_tests, support
@@ -585,6 +587,17 @@ class OrderedDictTests:
dict.update(od, [('spam', 1)])
self.assertNotIn('NULL', repr(od))
+ def test_reference_loop(self):
+ # Issue 25935
+ OrderedDict = self.OrderedDict
+ class A:
+ od = OrderedDict()
+ A.od[A] = None
+ r = weakref.ref(A)
+ del A
+ gc.collect()
+ self.assertIsNone(r())
+
class PurePythonOrderedDictTests(OrderedDictTests, unittest.TestCase):