[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit
STINNER Victor
report at bugs.python.org
Tue Sep 3 08:21:13 EDT 2019
STINNER Victor <vstinner at 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 <report at bugs.python.org>
<https://bugs.python.org/issue38006>
_______________________________________
More information about the Python-bugs-list
mailing list