Change FinalizingCache to cope with PyPy weakref callback behaviour.
Author: mithrandi
Reviewer: exarkun, lvh
On CPython, weakref callbacks always run before any other code has a chance to
observe the broken weakref. On PyPy, this is not the case; code may run between
the weakref being broken, and the weakref callback being run, thus potentially
encountering a weakref which is broken but has not (yet) had its callback
invoked. This branch makes changes to tolerate this situation.