Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee46cb6

Browse files
gh-105927: PyWeakref_GetRef() returns 1 on success (#106561)
PyWeakref_GetRef() now returns 1 on success, and return 0 if thereference is dead.Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent1e12c8c commitee46cb6

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

‎Doc/c-api/weakref.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ as much as it can.
5555
5656
Get a:term:`strong reference` to the referenced object from a weak
5757
reference, *ref*, into *\*pobj*.
58-
Return 0 on success. Raise an exception and return -1 on error.
5958
60-
If the referent is no longer live, set *\*pobj* to ``NULL`` and return 0.
59+
* On success, set *\*pobj* to a new:term:`strong reference` to the
60+
referenced object and return 1.
61+
* If the reference is dead, set *\*pobj* to ``NULL`` and return 0.
62+
* On error, raise an exception and return -1.
6163
6264
..versionadded::3.13
6365

‎Modules/_testcapimodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3376,7 +3376,7 @@ test_weakref_capi(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
33763376

33773377
// test PyWeakref_GetRef(), reference is alive
33783378
PyObject*ref=Py_True;// marker to check that value was set
3379-
assert(PyWeakref_GetRef(weakref,&ref)==0);
3379+
assert(PyWeakref_GetRef(weakref,&ref)==1);
33803380
assert(ref==obj);
33813381
assert(Py_REFCNT(obj)== (refcnt+1));
33823382
Py_DECREF(ref);

‎Objects/weakrefobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ PyWeakref_GetRef(PyObject *ref, PyObject **pobj)
913913
return-1;
914914
}
915915
*pobj=_PyWeakref_GET_REF(ref);
916-
return0;
916+
return(*pobj!=NULL);
917917
}
918918

919919

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp