[docs] Possible document issue.

Issaria Peng issaria at gmail.com
Fri Aug 2 16:01:59 CEST 2013


Hi,

http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst

509<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l509>
/*
Time to call the callback */
 510<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l510>
arglist
= Py_BuildValue("(i)", arg);
 511<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l511>
result
= PyObject_CallObject(my_callback, arglist);
 512<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l512>
Py_DECREF(arglist);
 513<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l513>
 514<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l514>
:c:func:`PyObject_CallObject`
returns a Python object pointer: this is the return
 515<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l515>value
of the Python function.
:c:func:`PyObject_CallObject` is
 516<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l516>"reference-count-neutral"
with respect to its arguments. In the example a
new
 517<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l517>tuple
was created to serve as the argument list, which is
:c:func:`Py_DECREF`\
 518<http://hg.python.org/cpython/file/52e166a975f9/Doc/extending/extending.rst#l518>-ed
immediately after the call.

According to the explain directly after the code, line 512 should be:

Py_DECREF(result);

Regards,
Isaiah Peng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20130802/f0aadff5/attachment-0001.html>


More information about the docs mailing list