Commit 502c3eb5 authored by Georg Brandl's avatar Georg Brandl

#8578: mention danger of not incref'ing weak referenced object.

parent 2d3c4e79
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment