BeautifulSoup modified to use weak refs and avoid circular links.

Delaney, Timothy (Tim) tdelaney at avaya.com
Sun Feb 25 18:05:11 EST 2007


John Nagle wrote:

>     "weakref.proxy()" probably should work that way.
> Weakref proxies are supposed to be transparent, but they're not
> quite transparent enough.

Submit a patch to SourceForge. Please don't use tabs in email/usenet
postings - use 4-space indents. "return" is not a function, and
comparisons with "None" should nearly always use "is".

I've also changed backref() to use isinstance(obj, tuple) (available in
Python 2.2 and later):

    def backref(p):
        if p is None:
            return None

        if isinstance(p, (weakref.ProxyType,
weakref.CallableProxyType)):
            return p

        return weakref.proxy(p)

Tim Delaney



More information about the Python-list mailing list