Skip to content

Conversation

2bndy5
Copy link
Contributor

@2bndy5 2bndy5 commented Oct 15, 2025

resolves #1434

Instead use PyList_GetItem() for python < 3.13 or PyList_GetItemRef() for python >= 3.13.

Both are part of the Stable ABI but also propagate errors. Whereas the previous PyList_GET_ITEM() did not do any error checking and was not part of the Stable ABI.

@2bndy5
Copy link
Contributor Author

2bndy5 commented Oct 15, 2025

I'd be more comfortable with this after #1433 is merged and this branch is rebased. That way all wheels are tested before merging.

I did test this locally using cibuildwheel on windows (x64).

@2bndy5 2bndy5 marked this pull request as draft October 15, 2025 06:39
Comment on lines +602 to +607
py_commit_oid =
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 13
PyList_GetItem(py_commit_oids, i);
#else
PyList_GetItemRef(py_commit_oids, i);
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no .clang-format file or documented code style guidelines. So I just copied the style I observed in src/pygit2.c

This comment was marked as off-topic.

resolves libgit2#1434

Instead use [`PyList_GetItem()`] for python < 3.13 or [`PyList_GetItemRef()`] for python >= 3.13.

Both are part of the Stable ABI but also propagate errors.
Whereas the previous [`PyList_GET_ITEM()`] did not do any error checking and was not part of the Stable ABI.

[`PyList_GetItemRef()`]: https://docs.python.org/3/c-api/list.html#c.PyList_GetItemRef
[`PyList_GetItem()`]: https://docs.python.org/3/c-api/list.html#c.PyList_GetItem
[`PyList_GET_ITEM()`]: https://docs.python.org/3/c-api/list.html#c.PyList_GET_ITEM
@2bndy5 2bndy5 force-pushed the replace-PyList_GET_ITEM branch from 158afd3 to 90569a5 Compare October 15, 2025 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace PyList_GET_ITEM usages on the free-threaded build

1 participant