The PyTuple_SET_ITEM() and PyList_SET_ITEM() functions don't check that the index is valid. It should be checked with an assertion. <!-- gh-linked-prs --> ### Linked PRs * gh-106164 * gh-111480 * gh-111618 * gh-111683 <!-- /gh-linked-prs -->