-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
gh-111789: Use PyDict_GetItemRef() in _ctypes #111828
gh-111789: Use PyDict_GetItemRef() in _ctypes #111828
Conversation
serhiy-storchaka
commented
Nov 7, 2023
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: Use PyDict_GetItemRef() #111789
Ping me when this PR is ready for review. Now it's marked as a draft. |
It is ready for review. I marked it as draft because I do not insist that all these changes should be applied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
*presult = NULL; | ||
return 0; | ||
int rc = PyDict_GetItemRef(dict, key, presult); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_PyDict_GetItemProxy() now returns 1 if PyDict_GetItemRef() returns 1 and PyWeakref_CheckProxy() is false. It's only called once with if (_PyDict_GetItemProxy(cache, key, &result) != 0) {
. So it's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it has the same semantic as PyDict_GetItemRef()
.
1 -- found, returns a strong reference
0 -- not found (or was destroyed)
-1 -- error
Co-authored-by: Victor Stinner <[email protected]>
} | ||
*presult = NULL; | ||
return 0; | ||
int rc = PyDict_GetItemRef(dict, key, presult); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it has the same semantic as PyDict_GetItemRef()
.
1 -- found, returns a strong reference
0 -- not found (or was destroyed)
-1 -- error