summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2016-12-27 13:23:43 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2016-12-27 13:23:43 (GMT)
commitd741ed492f17609109432f1bccac0c019a05471b (patch)
tree5b4425dfb7360f55993971d1b2fc9ebe7d1f00fa /Lib/test/test_weakref.py
parent34d0ac8027e23609e24588735b37b8d5a55f7223 (diff)
parente10ca3a0fe10d825689179e9958c70aef01f4230 (diff)
downloadcpython-d741ed492f17609109432f1bccac0c019a05471b.zip
cpython-d741ed492f17609109432f1bccac0c019a05471b.tar.gz
cpython-d741ed492f17609109432f1bccac0c019a05471b.tar.bz2
Issue #28427: old keys should not remove new values from
WeakValueDictionary when collecting from another thread.
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 9341c6d..43cf2c0 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -1676,6 +1676,18 @@ class MappingTestCase(TestBase):
x = d.pop(10, 10)
self.assertIsNot(x, None) # we never put None in there!
+ def test_threaded_weak_valued_consistency(self):
+ # Issue #28427: old keys should not remove new values from
+ # WeakValueDictionary when collecting from another thread.
+ d = weakref.WeakValueDictionary()
+ with collect_in_thread():
+ for i in range(200000):
+ o = RefCycle()
+ d[10] = o
+ # o is still alive, so the dict can't be empty
+ self.assertEqual(len(d), 1)
+ o = None # lose ref
+
from test import mapping_tests