del f[0]
self.assertEqual(f.result, 0)
+ def test_proxy_bool(self):
+ # Test clearing of SF bug #1170766
+ class List(list): pass
+ lyst = List()
+ self.assertEqual(bool(weakref.proxy(lyst)), bool(lyst))
+
def test_getweakrefcount(self):
o = C()
ref1 = weakref.ref(o)
(editors: check NEWS.help for information about editing NEWS using ReST.)
+What's New in Python 2.4.2a
+===========================
+
+Extension Modules
+-----------------
+
+- weakref proxy has incorrect __nonzero__ behavior. SF bug #1770766.
+
+
What's New in Python 2.4.1 final?
=================================
PyObject *o = PyWeakref_GET_OBJECT(proxy);
if (!proxy_checkref(proxy))
return -1;
- if (o->ob_type->tp_as_number &&
- o->ob_type->tp_as_number->nb_nonzero)
- return (*o->ob_type->tp_as_number->nb_nonzero)(o);
- else
- return 1;
+ return PyObject_IsTrue(o);
}
static void