[Tim] ... > surrogates = {Default.weakref(): default, Null.weakref(): null} > def _remove(k): > try: > del surrogates[k] > except KeyError: > pass FYI, if I fiddle that part to use the same kind of odd spelling Python's weak dicts stumbled into for other reasons: surrogates = {Default.weakref(): default, Null.weakref(): null} self._surrogates = surrogates # new def _remove(k, selfref=weakref.ref(self)): # changed self = selfref() # new if self is not None: # new try: del self._surrogates[k] # changed except KeyError: pass then the Zope3 unit tests don't leave anything in gc.garbage under 2.4b2 + patch-finalizer. A spattering of tests fail (2 failures + 3 errors), though, due to new TypeError: can't pickle weakref objects exceptions. Note that in this case the callbacks get invoked but are impotent: self isn't strongly reachable from the callbacks, so self is left in the unreachable set, and so the `selfref` weakref (which does not have a callback) gets cleared before gc starts breaking cycles: all the callbacks see selfref() return None.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4