Python 3.5
line 109: def remove(wr, selfref=ref(self)): replace with: def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
line 117: _remove_dead_weakref(d, wr.key) replace with: _atomic_removal(d, wr.key)
line 109: def remove(wr, selfref=ref(self)): replace with: def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
line 117: _remove_dead_weakref(d, wr.key) replace with: _atomic_removal(d, wr.key)