Avoid using borrowed references + other cleanups#429
Merged
lazka merged 13 commits intopygobject:mainfrom Nov 9, 2025
Merged
Conversation
in theory these can fail
return -1 on error, while still allowing NULL as a successfull result
This vendors some new API functions from python/pythoncapi-compat@e3efede Not everything since it triggers various compiler warnings and we only need a few, so let's try that for now.
Port to PyDict_GetItemRef and PyDict_GetItemStringRef so we get rid of borrowed references there.
Use PyModule_AddObjectRef() and PyModule_Add() instead.
In theory they can all fail
…ySequence_ITEM To avoid working with borrowed references
index is unsigned, so make sure we don't allow negative numbers there.
to avoid borrowed references
to avoid borrowed references
to avoid borrowed references
…signedLong Check the value before to avoid calling PyErr_Occurred
No longer needed with modern Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move to newer APIs to avoid borrowed references. Plus some error handling fixes that were noticed along the way.