Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 00d0cb6

Browse files
committed
Explained more differences between PyList_SetItem() and PyList_SET_ITEM().
In particular, the affect on existing list content was not sufficiently explained. This closes SF bug #429554.
1 parent 19b77cf commit 00d0cb6

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Doc/api/api.tex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,13 +3304,18 @@ \subsection{List Objects \label{listObjects}}
33043304
\begin{cfuncdesc}{int}{PyList_SetItem}{PyObject *list, int index,
33053305
PyObject *item}
33063306
Sets the item at index \var{index} in list to \var{item}.
3307-
\strong{Note:} This function ``steals'' a reference to \var{item}.
3307+
\strong{Note:} This function ``steals'' a reference to \var{item} and
3308+
discards a reference to an item already in the list at the affected
3309+
position.
33083310
\end{cfuncdesc}
33093311

33103312
\begin{cfuncdesc}{PyObject*}{PyList_SET_ITEM}{PyObject *list, int i,
33113313
PyObject *o}
33123314
Macro form of \cfunction{PyList_SetItem()} without error checking.
3313-
\strong{Note:} This function ``steals'' a reference to \var{item}.
3315+
\strong{Note:} This function ``steals'' a reference to \var{item},
3316+
and, unlike \cfunction{PyList_SetItem()}, does \emph{not} discard a
3317+
reference to any item that it being replaced. This is normally only
3318+
used to fill in new lists where there is no previous content..
33143319
\end{cfuncdesc}
33153320

33163321
\begin{cfuncdesc}{int}{PyList_Insert}{PyObject *list, int index,

0 commit comments

Comments
 (0)