Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdcb941

Browse files
committed
SF bug #978308, Spurious errors taking bool of dead pro
Need to return -1 on error. Needs backport.
1 parent bd7f76d commit bdcb941

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/test/test_weakref.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def check(proxy):
104104

105105
self.assertRaises(weakref.ReferenceError, check, ref1)
106106
self.assertRaises(weakref.ReferenceError, check, ref2)
107+
self.assertRaises(weakref.ReferenceError, bool, weakref.proxy(C()))
107108
self.assert_(self.cbcalled == 2)
108109

109110
def check_basic_ref(self, factory):

Objects/weakrefobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ proxy_nonzero(PyWeakReference *proxy)
504504
{
505505
PyObject *o = PyWeakref_GET_OBJECT(proxy);
506506
if (!proxy_checkref(proxy))
507-
return 1;
507+
return -1;
508508
if (o->ob_type->tp_as_number &&
509509
o->ob_type->tp_as_number->nb_nonzero)
510510
return (*o->ob_type->tp_as_number->nb_nonzero)(o);

0 commit comments

Comments
 (0)