STINNER Victor <vstin...@python.org> added the comment:
I failed to write a reproducer from scratch. So let me share my notes here. The first point is that remove() function of WeakValueDictionary keeps WeakValueDictionary.data alive like that: --- class NoisyDel: def __del__(self): print("dealloc data dict") def create_closure(): data = {0: NoisyDel()} def remove(): return data return remove remove = create_closure() print("clear ") remove = None print("exit") --- data is only deleted once remove is cleared. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38006> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com