Skip to content

Conversation

@jkrejcha
Copy link
Contributor

@jkrejcha jkrejcha commented Dec 31, 2024

Py_DECREF's comment incorrectly references _Py_IncRef which isn't used by decref. Both functions don't accept NULL but only _Py_DecRef is relevant for the decref function

@ghost
Copy link

ghost commented Dec 31, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Dec 31, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

Why change a comment that is wrong to one that is also wrong?

This is explained in a previous comment in the file:
If it may be NULL, use Py_XINCREF/Py_XDECREF instead.

I think this comment should be completely changed or removed.

@picnixz
Copy link
Member

picnixz commented Jan 1, 2025

The comment is more for internal purposes and implementation details explaining why we are using _Py_DecRef instead of Py_DecRef and for compatibility reasons.

The caller is not meant to pass NULL when using Py_DECREF at all, but the implementation may appear to allow it (at least until Python 3.10).

@jkrejcha
Copy link
Contributor Author

jkrejcha commented Jan 2, 2025

Indeed this appears to me to be the case. Py_DecRef (notably not Py_DECREF) is just be a thin wrapper around Py_XDECREF.

@picnixz picnixz changed the title Trivial: Fix typo in Py_DECREF comment Fix typo in Py_DECREF comment Feb 8, 2025
@picnixz
Copy link
Member

picnixz commented Feb 8, 2025

@vstinner I plan to merge this one without a commit message and the title as the commit title.

If you however think it's not needed, we can also close this PR (strictly speaking, the comment is also correct but weird considering the implementation and was likely a C/C error).

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. I confirm that I made a stupid copy/paste mistake here.

@picnixz picnixz self-assigned this Feb 24, 2025
@picnixz picnixz merged commit 31ef8fd into python:main Feb 25, 2025
53 checks passed
@picnixz
Copy link
Member

picnixz commented Feb 25, 2025

@vstinner In general, we backports docs fixes but by docs I mean docs in pure Python/rst docs. I barely encounter docs fixes at the C level, so do you want to backport this change?

@vstinner
Copy link
Member

I don't think that it's worth it to backport such change.

seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants