Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: ef57abdb6012c9c97cdd22b7bb1f82a645ae3141 authored by Anthony Baxter on 18 April 2007, 03:35:45 UTC
2.5.1 final
Tip revision: ef57abd
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