FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-106521: Add PyObject_GetOptionalAttr() function by serhiy-storchaka · Pull Request #106522 · python/cpython · GitHub

/ cpython Public

gh-106521: Add PyObject_GetOptionalAttr() function - #106522

Merged
serhiy-storchaka merged 11 commits into
python:mainfrom
serhiy-storchaka:PyObject_GetOptionalAttr
Jul 11, 2023
Merged

gh-106521: Add PyObject_GetOptionalAttr() function#106522
serhiy-storchaka merged 11 commits into
python:mainfrom
serhiy-storchaka:PyObject_GetOptionalAttr

Conversation

serhiy-storchaka commented Jul 7, 2023
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

It is a new name of former _PyObject_LookupAttr().


📚 Documentation preview 📚: https://cpython-previews--106522.org.readthedocs.build/

It is a new name of former _PyObject_LookupAttr().
serhiy-storchaka requested review from a team and encukou as code owners July 7, 2023 18:33
Comment thread Doc/c-api/object.rst Outdated
Comment thread Doc/c-api/object.rst Outdated
Comment thread Doc/whatsnew/3.13.rst Outdated
Comment thread Include/abstract.h Outdated

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.)

Comment thread Doc/c-api/object.rst


.. c:function:: int PyObject_GetOptionalAttrString(PyObject *obj, const char *attr_name, PyObject **result);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You may just say:

Similar to :c:func:`PyObject_GetOptionalAttr`, but *name* is a UTF-8 encoded string.

To not copy/paste the documentation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread Doc/c-api/object.rst Outdated
Comment thread Doc/c-api/object.rst Outdated
Comment thread Doc/whatsnew/3.13.rst Outdated
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Jul 11, 2023

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. Thanks for the update.

Copy link
Copy Markdown
Member Author

Thank you for review @carljm and @vstinner, and especially for your documentation suggestions.

serhiy-storchaka merged commit 579aa89 into python:main Jul 11, 2023
serhiy-storchaka deleted the PyObject_GetOptionalAttr branch July 11, 2023 19:13
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL