Lines Matching refs:weakref

5 import weakref
106 wr = weakref.ref(o)
120 ref1 = weakref.ref(o, self.callback)
121 ref2 = weakref.ref(o, self.callback)
142 self.ref = weakref.ref(c, callback)
143 ref1 = weakref.ref(c, callback)
148 self.assertRaises(TypeError, weakref.ref, c, callback=None)
153 ref1 = weakref.proxy(o, self.callback)
154 ref2 = weakref.proxy(o, self.callback)
160 self.assertRaises(weakref.ReferenceError, check, ref1)
161 self.assertRaises(weakref.ReferenceError, check, ref2)
162 self.assertRaises(weakref.ReferenceError, bool, weakref.proxy(C()))
167 ref = weakref.ref(o)
177 ref = weakref.ref(o, self.callback)
186 ref1 = weakref.ref(o)
189 proxy = weakref.proxy(o)
190 ref2 = weakref.ref(o)
195 proxy = weakref.proxy(o)
196 ref1 = weakref.ref(o)
197 ref2 = weakref.ref(o)
200 self.assertEqual(weakref.getweakrefcount(o), 2,
203 self.assertEqual(weakref.getweakrefcount(o), 1,
208 proxy1 = weakref.proxy(o)
209 ref = weakref.ref(o)
210 proxy2 = weakref.proxy(o)
216 self.check_proxy(o, weakref.proxy(o))
219 p = weakref.proxy(L)
233 p2 = weakref.proxy(L2)
237 p3 = weakref.proxy(L3)
252 self.assertIn("__unicode__", dir(weakref.proxy(instance)))
253 self.assertEqual(unicode(weakref.proxy(instance)), u"unicode")
260 p = weakref.proxy(o)
270 p = weakref.proxy(o)
284 self.check_shared_without_callback(weakref.ref)
287 self.check_shared_without_callback(weakref.proxy)
309 ref1 = weakref.proxy(o)
313 self.assertIs(type(ref1), weakref.CallableProxyType,
356 f = weakref.proxy(g)
364 self.assertEqual(bool(weakref.proxy(lyst)), bool(lyst))
368 ref1 = weakref.ref(o)
369 ref2 = weakref.ref(o, self.callback)
370 self.assertEqual(weakref.getweakrefcount(o), 2,
373 proxy1 = weakref.proxy(o)
374 proxy2 = weakref.proxy(o, self.callback)
375 self.assertEqual(weakref.getweakrefcount(o), 4,
379 self.assertEqual(weakref.getweakrefcount(o), 0,
384 self.assertEqual(weakref.getweakrefcount(1), 0,
389 ref1 = weakref.ref(o, self.callback)
390 ref2 = weakref.ref(o, self.callback)
392 self.assertEqual(weakref.getweakrefs(o), [ref2],
396 ref1 = weakref.ref(o, self.callback)
397 ref2 = weakref.ref(o, self.callback)
399 self.assertEqual(weakref.getweakrefs(o), [ref1],
403 self.assertEqual(weakref.getweakrefs(o), [],
407 self.assertEqual(weakref.getweakrefs(1), [],
414 p = weakref.proxy(f)
428 data[weakref.ref(f, remove)] = None
460 wr = weakref.ref(c, lambda ignore: gc.collect())
468 wr = weakref.ref(c1.i, lambda ignore: gc.collect())
495 I.wr = weakref.ref(J, I.acallback)
547 I.wr = weakref.ref(J, I.acallback)
571 c2.wr = weakref.ref(c1, c2.cb)
599 c2.wr = weakref.ref(c1, c2.cb)
628 c1.wr = weakref.ref(c2, c1.acallback)
629 c2.wr = weakref.ref(c1, c2.acallback)
633 wr = weakref.ref(C, C_went_away)
667 c.wr = weakref.ref(d, callback) # this won't trigger
668 d.wr = weakref.ref(callback, d.cb) # ditto
669 external_wr = weakref.ref(callback, safe_callback) # but this will
690 self.check_gc_during_creation(weakref.ref)
693 self.check_gc_during_creation(weakref.proxy)
715 weakref.ref(referenced, callback)
728 ref_from_del = weakref.ref(self)
735 r = weakref.ref(Exception)
748 weakref.ref(int)
749 a = weakref.ref(A, l.append)
754 b = weakref.ref(B, l.append)
765 a = weakref.ref(x)
766 b = weakref.ref(y)
767 c = weakref.ref(z)
768 d = weakref.ref(x)
797 a = weakref.ref(x)
798 b = weakref.ref(y)
817 wself = weakref.ref(self)
820 self.wparent = weakref.ref(parent, cb)
822 d = weakref.WeakKeyDictionary()
833 class MyRef(weakref.ref):
850 class MyRef(weakref.ref):
854 r2 = weakref.ref(o)
856 self.assertEqual(weakref.getweakrefs(o), [r2, r1])
857 self.assertEqual(weakref.getweakrefcount(o), 2)
859 self.assertEqual(weakref.getweakrefcount(o), 3)
860 refs = weakref.getweakrefs(o)
867 class MyRef(weakref.ref):
873 refs = weakref.getweakrefs(o)
878 class MyRef(weakref.ref):
881 return weakref.ref.__new__(type, ob, callback)
901 class MyRef(weakref.ref):
963 self.check_len_cycles(weakref.WeakKeyDictionary, lambda n, k: (k, n))
966 self.check_len_cycles(weakref.WeakValueDictionary, lambda n, k: (n, k))
993 self.check_len_race(weakref.WeakKeyDictionary, lambda k: (k, 1))
996 self.check_len_race(weakref.WeakValueDictionary, lambda k: (1, k))
1004 self.assertEqual(weakref.getweakrefcount(o), 1,
1023 dict = weakref.WeakValueDictionary()
1035 self.assertEqual(weakref.getweakrefcount(o), 1,
1216 dict = weakref.WeakKeyDictionary({o:364})
1221 dict = weakref.WeakKeyDictionary({o:364})
1222 dict2 = weakref.WeakKeyDictionary(dict)
1226 dict = weakref.WeakKeyDictionary()
1234 self.assertRaises(TypeError, weakref.WeakValueDictionary.__init__)
1235 self.assertRaises(TypeError, weakref.WeakValueDictionary, {}, {})
1236 self.assertRaises(TypeError, weakref.WeakValueDictionary, (), ())
1240 d = weakref.WeakValueDictionary(**{kw: o})
1245 dict = weakref.WeakValueDictionary()
1270 self.check_popitem(weakref.WeakValueDictionary,
1274 self.check_popitem(weakref.WeakKeyDictionary,
1295 self.check_setdefault(weakref.WeakValueDictionary,
1299 self.check_setdefault(weakref.WeakKeyDictionary,
1324 self.check_update(weakref.WeakValueDictionary,
1327 self.assertRaises(TypeError, weakref.WeakValueDictionary.update)
1328 d = weakref.WeakValueDictionary()
1335 d = weakref.WeakValueDictionary()
1341 self.check_update(weakref.WeakKeyDictionary,
1345 d = weakref.WeakKeyDictionary()
1356 d = weakref.WeakValueDictionary()
1367 d = weakref.WeakKeyDictionary()
1385 d = weakref.WeakKeyDictionary()
1426 d = weakref.WeakValueDictionary()
1434 d = weakref.WeakValueDictionary()
1444 d = weakref.WeakValueDictionary()
1459 type2test = weakref.WeakValueDictionary
1466 type2test = weakref.WeakKeyDictionary