Skip to content
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-106521: Add PyObject_GetOptionalAttr() function #106522

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 7, 2023

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 serhiy-storchaka requested review from a team and encukou as code owners July 7, 2023 18:33
Doc/c-api/object.rst Outdated Show resolved Hide resolved
Doc/c-api/object.rst Outdated Show resolved Hide resolved
Doc/whatsnew/3.13.rst Outdated Show resolved Hide resolved
Include/abstract.h Outdated Show resolved Hide resolved
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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
Member Author

Choose a reason for hiding this comment

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

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.

Doc/c-api/object.rst Outdated Show resolved Hide resolved
Doc/c-api/object.rst Outdated Show resolved Hide resolved
Doc/whatsnew/3.13.rst Outdated Show resolved Hide resolved
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Jul 11, 2023
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the update.

@serhiy-storchaka
Copy link
Member Author

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

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

None yet

4 participants