Skip to content

Make it clear Py_VISIT is a macro in the docs #133688

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

Merged
merged 2 commits into from
May 18, 2025

Conversation

da-woods
Copy link
Contributor

@da-woods da-woods commented May 8, 2025

It has the hidden return inside it, so to me the void return type is a little misleading because it implies that it behaves like a C function.


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

It has the hidden return inside it, so to me the `void` return type is a little misleading because it implies that it behaves like a C function.
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

There are a few other places where a function is documented instead of a macro, e.g. any of the reference count APIs. I'm not opposed to changing everything, but what's the benefit here?

@ZeroIntensity
Copy link
Member

Oh wait, bad example--the reference count APIs are static inline functions, not macros. Oops. Pretend I said Py_CLEAR.

@da-woods
Copy link
Contributor Author

There are a few other places where a function is documented instead of a macro, e.g. any of the reference count APIs. I'm not opposed to changing everything, but what's the benefit here?

My opinion is that most of the reference counting API could be substituted for a function (and in some cases, has been). The ones that really couldn't be replaced by a function like Py_SETREF are documented as macros.

Py_VISIT couldn't be implemented as a function because it has a return in it, and that's what I found confusing about the way it's currently documented.

Oh wait, bad example--the reference count APIs are static inline functions, not macros. Oops. Pretend I said Py_CLEAR.

My opinion would be that Py_CLEAR might be better documented as a macro.


I don't feel hugely strongly about this - I'm not going to argue if you don't think it's an improvement. But that's the reasoning for why I proposed the change.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Ok, yeah, let's go with this. Py_VISIT can return the caller, which isn't at all clear when it's documented as a function. Let's also fix Py_CLEAR in a follow-up.

@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 11, 2025
@ZeroIntensity ZeroIntensity requested a review from encukou May 11, 2025 16:53
@kumaraditya303 kumaraditya303 merged commit bb32f3c into python:main May 18, 2025
36 checks passed
@miss-islington-app
Copy link

Thanks @da-woods for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs May 18, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 18, 2025
(cherry picked from commit bb32f3c)

Co-authored-by: da-woods <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 18, 2025
(cherry picked from commit bb32f3c)

Co-authored-by: da-woods <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented May 18, 2025

GH-134186 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label May 18, 2025
@bedevere-app
Copy link

bedevere-app bot commented May 18, 2025

GH-134187 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label May 18, 2025
@da-woods da-woods deleted the visit-docs branch May 18, 2025 16:29
kumaraditya303 pushed a commit that referenced this pull request May 18, 2025
document `Py_VISIT` as a macro in the docs (GH-133688)
(cherry picked from commit bb32f3c)

Co-authored-by: da-woods <[email protected]>
kumaraditya303 pushed a commit that referenced this pull request May 18, 2025
document `Py_VISIT` as a macro in the docs (GH-133688)
(cherry picked from commit bb32f3c)

Co-authored-by: da-woods <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants