PyList_SetItem steals the item reference even on failure, so the error path must not call Py_DECREF on the same object. Co-authored-by: Cursor <cursoragent@cursor.com>