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 a-feld
Recipients a-feld, deekay, pablogsal, tim.peters
Date 2020-04-20.15:21:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587396097.98.0.0794398438186.issue40312@roundup.psfhosted.org>
In-reply-to
Content
Thanks for the explanation! I agree that "about to be finalized" is unclear in the docs :)

I still believe that having different behavior for the ordering of finalizers versus weakref callbacks depending on whether the path is through gc versus reference counting is a bug.

The callback should be able to assume that when it's running, the referent is actually dead. The execution of a weakref callback in our case results in items being dropped from a WeakValueDictionary prematurely (the object is still referenced, accessible, and alive at the time the weakref callback runs).

I've attached a patch that would cause weakref callbacks to run consistently after finalizers. With the patch applied, all tests in cpython appear to pass, but the code examples above now work consistently.
History
Date User Action Args
2020-04-20 15:21:38a-feldsetrecipients: + a-feld, tim.peters, pablogsal, deekay
2020-04-20 15:21:37a-feldsetmessageid: <1587396097.98.0.0794398438186.issue40312@roundup.psfhosted.org>
2020-04-20 15:21:37a-feldlinkissue40312 messages
2020-04-20 15:21:37a-feldcreate