summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/weakref.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-08-02 17:49:25 (GMT)
committerGeorg Brandl <georg@python.org>2010-08-02 17:49:25 (GMT)
commit502c3eb52f35a969eca350dc90412bb409495f1e (patch)
treefccdc6f25bf5ae79bb73c9982075a0a48d609b78 /Doc/c-api/weakref.rst
parent2d3c4e79a19d8052d756575775a643a7107dced7 (diff)
downloadcpython-502c3eb52f35a969eca350dc90412bb409495f1e.zip
cpython-502c3eb52f35a969eca350dc90412bb409495f1e.tar.gz
cpython-502c3eb52f35a969eca350dc90412bb409495f1e.tar.bz2
#8578: mention danger of not incref'ing weak referenced object.
Diffstat (limited to 'Doc/c-api/weakref.rst')
-rw-r--r--Doc/c-api/weakref.rst9
1 files changed, 8 insertions, 1 deletions
diff --git a/Doc/c-api/weakref.rst b/Doc/c-api/weakref.rst
index 081419d..8a36110 100644
--- a/Doc/c-api/weakref.rst
+++ b/Doc/c-api/weakref.rst
@@ -53,7 +53,14 @@ as much as it can.
.. cfunction:: PyObject* PyWeakref_GetObject(PyObject *ref)
Return the referenced object from a weak reference, *ref*. If the referent is
- no longer live, returns ``None``.
+ no longer live, returns :const:`Py_None`.
+
+ .. warning::
+
+ This function returns a **borrowed reference** to the referenced object.
+ This means that you should always call :cfunc:`Py_INCREF` on the object
+ except if you know that it cannot be destroyed while you are still
+ using it.
.. cfunction:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)