Lines Matching refs:weakref

5 import weakref
110 wr = weakref.ref(o)
126 wr = weakref.ref(f)
135 ref1 = weakref.ref(o, self.callback)
136 ref2 = weakref.ref(o, self.callback)
157 self.ref = weakref.ref(c, callback)
158 ref1 = weakref.ref(c, callback)
163 self.assertRaises(TypeError, weakref.ref, c, callback=None)
168 ref1 = weakref.proxy(o, self.callback)
169 ref2 = weakref.proxy(o, self.callback)
177 self.assertRaises(ReferenceError, bool, weakref.proxy(C()))
182 ref = weakref.ref(o)
192 ref = weakref.ref(o, self.callback)
201 ref1 = weakref.ref(o)
204 proxy = weakref.proxy(o)
205 ref2 = weakref.ref(o)
210 proxy = weakref.proxy(o)
211 ref1 = weakref.ref(o)
212 ref2 = weakref.ref(o)
215 self.assertEqual(weakref.getweakrefcount(o), 2,
218 self.assertEqual(weakref.getweakrefcount(o), 1,
223 proxy1 = weakref.proxy(o)
224 ref = weakref.ref(o)
225 proxy2 = weakref.proxy(o)
231 self.check_proxy(o, weakref.proxy(o))
234 p = weakref.proxy(L)
247 p2 = weakref.proxy(L2)
251 p3 = weakref.proxy(L3)
265 self.assertIn("__bytes__", dir(weakref.proxy(instance)))
266 self.assertEqual(bytes(weakref.proxy(instance)), b"bytes")
273 p = weakref.proxy(o)
283 p = weakref.proxy(o)
297 self.check_shared_without_callback(weakref.ref)
300 self.check_shared_without_callback(weakref.proxy)
322 ref1 = weakref.proxy(o)
326 self.assertIs(type(ref1), weakref.CallableProxyType,
369 f = weakref.proxy(g)
377 self.assertEqual(bool(weakref.proxy(lyst)), bool(lyst))
381 ref1 = weakref.ref(o)
382 ref2 = weakref.ref(o, self.callback)
383 self.assertEqual(weakref.getweakrefcount(o), 2,
386 proxy1 = weakref.proxy(o)
387 proxy2 = weakref.proxy(o, self.callback)
388 self.assertEqual(weakref.getweakrefcount(o), 4,
392 self.assertEqual(weakref.getweakrefcount(o), 0,
397 self.assertEqual(weakref.getweakrefcount(1), 0,
402 ref1 = weakref.ref(o, self.callback)
403 ref2 = weakref.ref(o, self.callback)
405 self.assertEqual(weakref.getweakrefs(o), [ref2],
409 ref1 = weakref.ref(o, self.callback)
410 ref2 = weakref.ref(o, self.callback)
412 self.assertEqual(weakref.getweakrefs(o), [ref1],
416 self.assertEqual(weakref.getweakrefs(o), [],
420 self.assertEqual(weakref.getweakrefs(1), [],
427 p = weakref.proxy(f)
441 data[weakref.ref(f, remove)] = None
473 wr = weakref.ref(c, lambda ignore: gc.collect())
481 wr = weakref.ref(c1.i, lambda ignore: gc.collect())
508 I.wr = weakref.ref(J, I.acallback)
560 I.wr = weakref.ref(J, I.acallback)
584 c2.wr = weakref.ref(c1, c2.cb)
612 c2.wr = weakref.ref(c1, c2.cb)
641 c1.wr = weakref.ref(c2, c1.acallback)
642 c2.wr = weakref.ref(c1, c2.acallback)
646 wr = weakref.ref(C, C_went_away)
680 c.wr = weakref.ref(d, callback) # this won't trigger
681 d.wr = weakref.ref(callback, d.cb) # ditto
682 external_wr = weakref.ref(callback, safe_callback) # but this will
703 self.check_gc_during_creation(weakref.ref)
706 self.check_gc_during_creation(weakref.proxy)
728 weakref.ref(referenced, callback)
741 ref_from_del = weakref.ref(self)
748 r = weakref.ref(Exception)
758 weakref.ref(int)
759 a = weakref.ref(A, l.append)
770 a = weakref.ref(x)
771 b = weakref.ref(y)
772 c = weakref.ref(z)
773 d = weakref.ref(x)
803 a = weakref.ref(x)
804 b = weakref.ref(y)
817 a = weakref.ref(x)
818 b = weakref.ref(y)
837 wself = weakref.ref(self)
840 self.wparent = weakref.ref(parent, cb)
842 d = weakref.WeakKeyDictionary()
852 ref1 = weakref.ref(x, callback)
855 ref2 = weakref.ref(x)
860 ref = weakref.ref(x, self.callback)
869 ref1 = weakref.ref(x, callback)
877 ref1 = weakref.ref(x, lambda ref: support.gc_collect())
885 class MyRef(weakref.ref):
902 class MyRef(weakref.ref):
906 r2 = weakref.ref(o)
908 self.assertEqual(weakref.getweakrefs(o), [r2, r1])
909 self.assertEqual(weakref.getweakrefcount(o), 2)
911 self.assertEqual(weakref.getweakrefcount(o), 3)
912 refs = weakref.getweakrefs(o)
919 class MyRef(weakref.ref):
925 refs = weakref.getweakrefs(o)
930 class MyRef(weakref.ref):
933 return weakref.ref.__new__(type, ob, callback)
953 class MyRef(weakref.ref):
996 r = weakref.WeakMethod(o.some_method)
997 self.assertIsInstance(r, weakref.ReferenceType)
1005 r = weakref.WeakMethod(o.some_method)
1013 r = weakref.WeakMethod(o.some_method)
1025 r = weakref.WeakMethod(o.some_method, cb)
1041 r = weakref.WeakMethod(o.some_method, cb)
1056 r = weakref.WeakMethod(o.some_method, cb)
1057 wr = weakref.ref(r)
1070 a = weakref.WeakMethod(x.some_method)
1071 b = weakref.WeakMethod(y.some_method)
1072 c = weakref.WeakMethod(x.other_method)
1073 d = weakref.WeakMethod(y.other_method)
1084 e = weakref.WeakMethod(z.some_method)
1085 f = weakref.WeakMethod(z.other_method)
1104 a = weakref.WeakMethod(x.some_method)
1105 b = weakref.WeakMethod(y.some_method)
1106 c = weakref.WeakMethod(y.other_method)
1144 self.check_len_cycles(weakref.WeakKeyDictionary, lambda k: (k, 1))
1147 self.check_len_cycles(weakref.WeakValueDictionary, lambda k: (1, k))
1174 self.check_len_race(weakref.WeakKeyDictionary, lambda k: (k, 1))
1177 self.check_len_race(weakref.WeakValueDictionary, lambda k: (1, k))
1185 self.assertEqual(weakref.getweakrefcount(o), 1)
1203 dict = weakref.WeakValueDictionary()
1215 self.assertEqual(weakref.getweakrefcount(o), 1,
1438 dict = weakref.WeakKeyDictionary({o:364})
1443 dict = weakref.WeakKeyDictionary({o:364})
1444 dict2 = weakref.WeakKeyDictionary(dict)
1448 dict = weakref.WeakKeyDictionary()
1456 dict = weakref.WeakValueDictionary({364:o})
1461 dict = weakref.WeakValueDictionary({364:o})
1462 dict2 = weakref.WeakValueDictionary(dict)
1467 self.assertRaises(TypeError, weakref.WeakValueDictionary.__init__)
1468 self.assertRaises(TypeError, weakref.WeakValueDictionary, {}, {})
1469 self.assertRaises(TypeError, weakref.WeakValueDictionary, (), ())
1473 d = weakref.WeakValueDictionary(**{kw: o})
1478 dict = weakref.WeakValueDictionary()
1503 self.check_popitem(weakref.WeakValueDictionary,
1507 self.check_popitem(weakref.WeakKeyDictionary,
1528 self.check_setdefault(weakref.WeakValueDictionary,
1532 self.check_setdefault(weakref.WeakKeyDictionary,
1555 self.check_update(weakref.WeakValueDictionary,
1558 self.assertRaises(TypeError, weakref.WeakValueDictionary.update)
1559 d = weakref.WeakValueDictionary()
1566 d = weakref.WeakValueDictionary()
1572 self.check_update(weakref.WeakKeyDictionary,
1576 d = weakref.WeakKeyDictionary()
1587 d = weakref.WeakValueDictionary()
1598 d = weakref.WeakKeyDictionary()
1616 d = weakref.WeakKeyDictionary()
1657 dict = weakref.WeakValueDictionary()
1661 dict = weakref.WeakKeyDictionary()
1665 d = weakref.WeakValueDictionary()
1673 d = weakref.WeakValueDictionary()
1683 d = weakref.WeakValueDictionary()
1723 self.assertIn(type_, (weakref.WeakKeyDictionary, weakref.WeakValueDictionary))
1738 if type_ is weakref.WeakKeyDictionary:
1756 self.check_threaded_weak_dict_copy(weakref.WeakKeyDictionary, False)
1761 self.check_threaded_weak_dict_copy(weakref.WeakKeyDictionary, True)
1766 self.check_threaded_weak_dict_copy(weakref.WeakValueDictionary, False)
1771 self.check_threaded_weak_dict_copy(weakref.WeakValueDictionary, True)
1779 type2test = weakref.WeakValueDictionary
1786 type2test = weakref.WeakKeyDictionary
1809 f = weakref.finalize(a, add, 67, 43, z=89)
1821 f = weakref.finalize(a, add, 67, 43, 89)
1832 f = weakref.finalize(a, add, x=67, y=43, z=89)
1846 f1 = weakref.finalize(a, res.append, 'f1')
1847 f2 = weakref.finalize(a, res.append, 'f2')
1848 f3 = weakref.finalize(a, res.append, 'f3')
1849 f4 = weakref.finalize(a, res.append, 'f4')
1850 f5 = weakref.finalize(a, res.append, 'f5')
1883 class MyFinalizer(weakref.finalize):
1892 wr_callback = weakref.ref(callback)
1893 wr_f = weakref.ref(f)
1911 g1 = weakref.finalize(cls, print, 'g1')
1916 f1 = weakref.finalize(cls, print, 'f1', _global_var)
1917 f2 = weakref.finalize(cls, print, 'f2', _global_var)
1918 f3 = weakref.finalize(cls, error)
1919 f4 = weakref.finalize(cls, print, 'f4', _global_var)