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-110481: Non-limited Py_INCREF/DECREF() in cpython/object.h #111505

Closed
wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 30, 2023

Move the non-limited implementation of Py_INCREF() and Py_DECREF() from Include/object.h to Include/cpython/object.h.

Move static inline functions using Py_INCREF/DECREF() after the cpython/object.h include: Py_XINCREF(), Py_XDECREF(), Py_NewRef() and Py_XNewRef().

Move the non-limited implementation of Py_INCREF() and Py_DECREF()
from Include/object.h to Include/cpython/object.h.

Move static inline functions using Py_INCREF/DECREF() after the
cpython/object.h include: Py_XINCREF(), Py_XDECREF(), Py_NewRef() and
Py_XNewRef().
@colesbury
Copy link
Contributor

Cool - I didn't think this was going to be possible.

I'm seeing some build failures locally in modules that target Py_LIMITED_API < 0x030c0000. These don't include either definition of Py_INCREF/DECREF because Include/cpython/object.h is only include if Py_LIMITED_API is NOT defined and the Include/object.h definition is only for Py_LIMITED_API >= 0x030c0000 (or debug builds).

In file included from ./Include/Python.h:52,
                 from ./Modules/_testimportmultiple.c:15:
./Include/object.h: In function ‘Py_XINCREF’:
./Include/object.h:968:9: error: implicit declaration of function ‘Py_INCREF’; did you mean ‘Py_XINCREF’? [-Werror=implicit-function-declaration]
  968 |         Py_INCREF(op);
      |         ^~~~~~~~~
      |         Py_XINCREF

@vstinner vstinner marked this pull request as draft October 30, 2023 17:00
@vstinner
Copy link
Member Author

Cool - I didn't think this was going to be possible.

Sadly, it doesn't work because of Py_LIMITED_API+0 >= 0x030c0000 test in #if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)). I should think about a different approach.

@vstinner vstinner closed this Oct 30, 2023
@vstinner vstinner deleted the cpython_incref branch October 30, 2023 17:18
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.

2 participants