Message366844
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. |
|
Date |
User |
Action |
Args |
2020-04-20 15:21:38 | a-feld | set | recipients:
+ a-feld, tim.peters, pablogsal, deekay |
2020-04-20 15:21:37 | a-feld | set | messageid: <1587396097.98.0.0794398438186.issue40312@roundup.psfhosted.org> |
2020-04-20 15:21:37 | a-feld | link | issue40312 messages |
2020-04-20 15:21:37 | a-feld | create | |
|