File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,10 @@ The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type:
232232 object argument. If *visit * returns a non-zero value that value should be
233233 returned immediately.
234234
235+ The traversal function must not have any side effects. Implementations
236+ may not modify the reference counts of any Python objects nor create or
237+ destroy any Python objects.
238+
235239To simplify writing :c:member: `~PyTypeObject.tp_traverse ` handlers, a :c:func: `Py_VISIT ` macro is
236240provided. In order to use this macro, the :c:member: `~PyTypeObject.tp_traverse ` implementation
237241must name its arguments exactly *visit * and *arg *:
Original file line number Diff line number Diff line change @@ -1569,6 +1569,11 @@ and :c:data:`PyType_Type` effectively act as defaults.)
15691569 but the instance has no strong reference to the elements inside it, as they
15701570 are allowed to be removed even if the instance is still alive).
15711571
1572+ .. warning ::
1573+ The traversal function must not have any side effects. It must not
1574+ modify the reference counts of any Python objects nor create or destroy
1575+ any Python objects.
1576+
15721577 Note that :c:func: `Py_VISIT ` requires the *visit * and *arg * parameters to
15731578 :c:func: `!local_traverse ` to have these specific names; don't name them just
15741579 anything.
You can’t perform that action at this time.
0 commit comments