From bdcb9410c20c49928c91b065ccbd115aa450e037 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Thu, 8 Jul 2004 01:22:31 +0000 Subject: SF bug #978308, Spurious errors taking bool of dead pro Need to return -1 on error. Needs backport. --- Lib/test/test_weakref.py | 1 + Objects/weakrefobject.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 31e2c7f..75869a7 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -104,6 +104,7 @@ class ReferencesTestCase(TestBase): self.assertRaises(weakref.ReferenceError, check, ref1) self.assertRaises(weakref.ReferenceError, check, ref2) + self.assertRaises(weakref.ReferenceError, bool, weakref.proxy(C())) self.assert_(self.cbcalled == 2) def check_basic_ref(self, factory): diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 572c224..54fe446 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -504,7 +504,7 @@ proxy_nonzero(PyWeakReference *proxy) { PyObject *o = PyWeakref_GET_OBJECT(proxy); if (!proxy_checkref(proxy)) - return 1; + 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); -- cgit v0.12