Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 28dbc1f83e5bdc3f879a8a9d659908d2d476a1d9 authored by Barry Warsaw on 26 October 2009, 01:48:07 UTC
bumping to 2.6.4
Tip revision: 28dbc1f
borrowed_ref_1.py
"""
_PyType_Lookup() returns a borrowed reference.
This attacks the call in dictobject.c.
"""

class A(object):
    pass

class B(object):
    def __del__(self):
        print 'hi'
        del D.__missing__

class D(dict):
    class __missing__:
        def __init__(self, *args):
            pass


d = D()
a = A()
a.cycle = a
a.other = B()
del a

prev = None
while 1:
    d[5]
    prev = (prev,)
back to top