[issue17816] Weak*Dictionary KeyErrors during callbacks

2020-11-17 Thread Irit Katriel
Irit Katriel added the comment: This was fixed in Python 3 and Python 2 is past its EOL. -- nosy: +iritkatriel resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker __

[issue17816] Weak*Dictionary KeyErrors during callbacks

2013-05-01 Thread Nils Bruin
Nils Bruin added the comment: One solution is to patch both WeakValueDictionary and WeakKeyDictionary with their own clear methods where we first store the strong links (to keys, resp. values) in a list, then clear the underlying dictionaries (this will now trigger the deletion of the weakrefs

[issue17816] Weak*Dictionary KeyErrors during callbacks

2013-04-22 Thread Nils Bruin
Nils Bruin added the comment: I think the difference in behaviour between Py3 and Py2 is coming from: http://hg.python.org/cpython/file/a26df2d03989/Objects/dictobject.c#l1275 which first clears all values before removing any keys. For a WeakValueDictionary that means all the weakrefs are neut

[issue17816] Weak*Dictionary KeyErrors during callbacks

2013-04-22 Thread Nils Bruin
Nils Bruin added the comment: Have you tried if the fix at issue7105 solves the problem? I don't see the patch there introduce a `clear` method override for WeakValueDictionary or WeakKeyDictionary. The one for WeakSet still calls self.data.clear(), which for dictionaries would still result in

[issue17816] Weak*Dictionary KeyErrors during callbacks

2013-04-22 Thread Volker Braun
Volker Braun added the comment: This is http://bugs.python.org/issue7105. The patch from there could easily be backported, I think. -- nosy: +vbraun ___ Python tracker ___ _

[issue17816] Weak*Dictionary KeyErrors during callbacks

2013-04-22 Thread Nils Bruin
New submission from Nils Bruin: The following program is a little dependent on memory layout but will usually generate lots of Exception KeyError: (A(9996),) in ignored messages in Python 2.7. import weakref class A(object): def __init__(self,n): self.n=n