Skip to content

Commit d000b55

Browse files
committed
PyWeakref_GetRef() returns 1 on success
See upstream change: python/cpython@ee46cb6
1 parent 6c49cf3 commit d000b55

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pythoncapi_compat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ PyWeakref_GetRef(PyObject *ref, PyObject **pobj)
603603
return 0;
604604
}
605605
*pobj = Py_NewRef(obj);
606-
return 0;
606+
return (*pobj != NULL);
607607
}
608608
#endif
609609

tests/test_pythoncapi_compat_cext.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ test_weakref(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
710710

711711
// test PyWeakref_GetRef(), reference is alive
712712
PyObject *ref = Py_True; // marker to check that value was set
713-
assert(PyWeakref_GetRef(weakref, &ref) == 0);
713+
assert(PyWeakref_GetRef(weakref, &ref) == 1);
714714
assert(ref == obj);
715715
assert(Py_REFCNT(obj) == (refcnt + 1));
716716
Py_DECREF(ref);

0 commit comments

Comments
 (0)