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, so all callbacks are neutralized), and 
then delete the list. It does use more storage that way, but it gets rid of the 
ignored key errors.

This is a different problem from issue7105, which deals with the (much more 
complicated) scenario of avoiding dictionary reshaping due to GC when iterators 
are still (potentially) active.

----------
keywords: +patch
Added file: http://bugs.python.org/file30101/17816_custom_clear.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17816>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to