mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bug [ 1228904 ] weakref example broken
This commit is contained in:
parent
1c330eb9eb
commit
376e6227b4
1 changed files with 2 additions and 5 deletions
|
|
@ -255,13 +255,10 @@ returned when the referent is accessed:
|
|||
import weakref
|
||||
|
||||
class ExtendedRef(weakref.ref):
|
||||
def __new__(cls, ob, callback=None, **annotations):
|
||||
weakref.ref.__new__(cls, ob, callback)
|
||||
self.__counter = 0
|
||||
|
||||
def __init__(self, ob, callback=None, **annotations):
|
||||
super(ExtendedRef, self).__init__(ob, callback)
|
||||
for k, v in annotations:
|
||||
self.__counter = 0
|
||||
for k, v in annotations.iteritems():
|
||||
setattr(self, k, v)
|
||||
|
||||
def __call__(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue