Message406357
The issue described issue7105 (and maybe issue7060) still exists due to a race condition in WeakKeyDictionary. This shows up as test failure that looks like:
test test_weakref failed -- Traceback (most recent call last):
File "Lib/test/test_weakref.py", line 1960, in test_threaded_weak_value_dict_deepcopy
self.check_threaded_weak_dict_copy(weakref.WeakValueDictionary, True)
File "Lib/test/test_weakref.py", line 1940, in check_threaded_weak_dict_copy
raise exc[0]
File "Lib/test/test_weakref.py", line 1897, in dict_copy
_ = copy.deepcopy(d)
File "Lib/copy.py", line 153, in deepcopy
y = copier(memo)
File "Lib/weakref.py", line 189, in __deepcopy__
for key, wr in self.data.items():
RuntimeError: dictionary changed size during iteration
The cause is that the check of "self._iterating" and the call to "_atomic_removal" are not performed atomically together. By the time _atomic_removal() is called, an iteration might have already started.
https://github.com/python/cpython/blob/ec382fac0db6d9159c2d3496a70b7a605545957e/Lib/weakref.py#L109-L114 |
|
Date |
User |
Action |
Args |
2021-11-15 19:02:38 | colesbury | set | recipients:
+ colesbury |
2021-11-15 19:02:38 | colesbury | set | messageid: <1637002958.39.0.243945007085.issue45809@roundup.psfhosted.org> |
2021-11-15 19:02:38 | colesbury | link | issue45809 messages |
2021-11-15 19:02:38 | colesbury | create | |
|