A couple of examples about how to attack the fact that _PyType_Lookup()

returns a borrowed ref.  Many of the calls are open to attack.
This commit is contained in:
Armin Rigo 2006-07-06 07:58:18 +00:00
parent 43d9a58dfd
commit 5953baca0a
2 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,29 @@
"""
_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,)