mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #14211: _PyObject_GenericSetAttrWithDict() keeps a strong reference to
the descriptor because it may be destroyed before being used, destroyed during the update of the dict for example.
This commit is contained in:
parent
d74782b0ac
commit
2d01dc00bc
2 changed files with 5 additions and 33 deletions
|
@ -1,29 +0,0 @@
|
|||
"""
|
||||
_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,)
|
Loading…
Add table
Add a link
Reference in a new issue