This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Mark.Shannon, christian.heimes, jdemeyer, lukasz.langa, pablogsal, petr.viktorin, pitrou, vstinner
Date 2019-09-03.12:21:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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 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

data is only deleted once remove is cleared.
Date User Action Args
2019-09-03 12:21:13vstinnersetrecipients: + vstinner, pitrou, christian.heimes, petr.viktorin, lukasz.langa, Mark.Shannon, jdemeyer, pablogsal
2019-09-03 12:21:13vstinnersetmessageid: <>
2019-09-03 12:21:13vstinnerlinkissue38006 messages
2019-09-03 12:21:13vstinnercreate