-
-
Notifications
You must be signed in to change notification settings - Fork 404
fix: replace PyList_GET_ITEM()
#1435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
90569a5
to
8ada517
Compare
PyList_GetItem returns a borrowed reference (like PyList_GET_ITEM) while PyList_GetItemRef returns a new reference, so you have to choose one, in this case use always PyList_GetItem regardless of the Python version. |
#1435 describes why We could use a compatibility layer ( |
I think we should add an implementation of PyList_GetItemRef for versions older than 3.13, then use it. |
8ada517
to
465b44b
Compare
Ok. I've added the conditional definition of I'm not well accustomed to using the Python C API directly. So, thank you for reviewing this and giving feedback. |
resolves libgit2#1434 Instead use [`PyList_GetItemRef()`] for python >= 3.13. Internally, this function is conditionally defined for python < 3.13. [`PyList_GetItemRef()`] is 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_GET_ITEM()`]: https://docs.python.org/3/c-api/list.html#c.PyList_GET_ITEM
465b44b
to
48c178f
Compare
resolves #1434
Instead use
PyList_GetItemRef()
for python >= 3.13. Internally, this function is conditionally defined for python < 3.13.PyList_GetItemRef()
is part of the Stable ABI but also propagate errors. Whereas the previousPyList_GET_ITEM()
did not do any error checking and was not part of the Stable ABI.