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

Skip to content

Commit a937d14

Browse files
committed
Fred's right -- we need PyList_SET_ITEM().
1 parent 7b7a2c2 commit a937d14

4 files changed

Lines changed: 12 additions & 1 deletion

File tree

Doc/api.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,11 @@ \subsection{List Objects}
19531953
Macro form of \cfunction{PyList_GetItem()} without error checking.
19541954
\end{cfuncdesc}
19551955
1956+
\begin{cfuncdesc}{PyObject*}{PyList_SET_ITEM}{PyObject *list, int i,
1957+
PyObject *o}
1958+
Macro form of \cfunction{PyList_SetItem()} without error checking.
1959+
\end{cfuncdesc}
1960+
19561961
\begin{cfuncdesc}{int}{PyList_GET_SIZE}{PyObject *list}
19571962
Macro form of \cfunction{PyList_GetSize()} without error checking.
19581963
\end{cfuncdesc}

Doc/api/api.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,11 @@ \subsection{List Objects}
19531953
Macro form of \cfunction{PyList_GetItem()} without error checking.
19541954
\end{cfuncdesc}
19551955
1956+
\begin{cfuncdesc}{PyObject*}{PyList_SET_ITEM}{PyObject *list, int i,
1957+
PyObject *o}
1958+
Macro form of \cfunction{PyList_SetItem()} without error checking.
1959+
\end{cfuncdesc}
1960+
19561961
\begin{cfuncdesc}{int}{PyList_GET_SIZE}{PyObject *list}
19571962
Macro form of \cfunction{PyList_GetSize()} without error checking.
19581963
\end{cfuncdesc}

Include/listobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ extern PyObject *PyList_AsTuple Py_PROTO((PyObject *));
7474

7575
/* Macro, trading safety for speed */
7676
#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
77+
#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
7778
#define PyList_GET_SIZE(op) (((PyListObject *)(op))->ob_size)
7879

7980
#ifdef __cplusplus

Python/bltinmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ builtin_range(self, args)
12821282
Py_DECREF(v);
12831283
return NULL;
12841284
}
1285-
PyList_GET_ITEM(v, i) = w;
1285+
PyList_SET_ITEM(v, i, w);
12861286
ilow += istep;
12871287
}
12881288
return v;

0 commit comments

Comments
 (0)