A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-November/049817.html below:

[Python-Dev] patch-finalizer vs Zope3

[Python-Dev] patch-finalizer vs Zope3 [Python-Dev] patch-finalizer vs Zope3Tim Peters tim.peters at gmail.com
Sun Nov 7 06:07:37 CET 2004
[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.
More information about the Python-Dev mailing list

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