summaryrefslogtreecommitdiff
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2016-12-27 14:19:20 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2016-12-27 14:19:20 +0100
commite10ca3a0fe10d825689179e9958c70aef01f4230 (patch)
treef7dc9b56ba188d143a616062ec9e47f434aa32a3 /Lib/test/test_weakref.py
parent1fee5151f72e4e141eb37e7ab0da901d1b610f45 (diff)
downloadcpython-git-e10ca3a0fe10d825689179e9958c70aef01f4230.tar.gz
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 28a1cc2bfa..1aa354019d 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -1673,6 +1673,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