gh-106521: Add PyObject_GetOptionalAttr() function#106522
Merged
serhiy-storchaka merged 11 commits intopython:mainfrom Jul 11, 2023
Merged
gh-106521: Add PyObject_GetOptionalAttr() function#106522serhiy-storchaka merged 11 commits intopython:mainfrom
serhiy-storchaka merged 11 commits intopython:mainfrom
Conversation
It is a new name of former _PyObject_LookupAttr().
carljm
reviewed
Jul 7, 2023
vstinner
reviewed
Jul 10, 2023
Member
vstinner
left a comment
There was a problem hiding this comment.
To ease the review, you might keep the old name with an alias #define _PyObject_LookupAttr PyObject_GetOptionalAttr, and then write a second PR to update usage of the old name. (Well, just split the PR in two parts.)
|
|
||
|
|
||
| .. c:function:: int PyObject_GetOptionalAttrString(PyObject *obj, const char *attr_name, PyObject **result); | ||
|
|
Member
There was a problem hiding this comment.
You may just say:
Similar to :c:func:`PyObject_GetOptionalAttr`, but *name* is a UTF-8 encoded string.
To not copy/paste the documentation.
Member
Author
There was a problem hiding this comment.
In all other functions with String suffix the documentation is repeated. If we are going to change this, it should be changed for all function at once.
Co-authored-by: Victor Stinner <vstinner@python.org>
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this pull request
Jul 11, 2023
vstinner
approved these changes
Jul 11, 2023
Member
vstinner
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the update.
Member
Author
hauntsaninja
pushed a commit
to python/mypy
that referenced
this pull request
Jul 7, 2024
`_PyObject_LookupAttrId` was removed / replaced with `PyObject_GetOptionalAttrString` in python/cpython#106522. https://docs.python.org/dev/c-api/object.html#c.PyObject_GetOptionalAttrString Fixes ```cpp /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h: In function ‘update_bases’: (diff) /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h:51:13: error: implicit declaration of function ‘_PyObject_LookupAttrId’; did you mean ‘_PyObject_GetAttrId’? [-Werror=implicit-function-declaration] (diff) 51 | if (_PyObject_LookupAttrId(base, &PyId___mro_entries__, &meth) < 0) { (diff) | ^~~~~~~~~~~~~~~~~~~~~~ (diff) | _PyObject_GetAttrId (diff) ```
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.
It is a new name of former _PyObject_LookupAttr().
📚 Documentation preview 📚: https://cpython-previews--106522.org.readthedocs.build/