-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: Don't wrap #include <Python.h>
with extern "C"
#27986
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
Conversation
This extern block was recently moved, which exposed a latent bug in CPython (python/cpython#127772), but it's probably not a good practice in general to wrap other code's headers with extern guards.
This was found to cause a build failure in Google's monorepo. It's unlikely to cause issues elsewhere, since you need to have a particular combination of includes from a C++ build to notice the problem. Still, we may as well fix it. |
Harmless enough and I don't mind just merging. Is that really a best-practice -- considering Python is a C-API -- to rely on them having the |
The Python C API docs say they include the appropriate
|
(As it happens, they did not. But I sent a PR fixing that in CPython, see above.) |
#include <Python.h>
with extern "C"
.#include <Python.h>
with extern "C"
.
#include <Python.h>
with extern "C"
.#include <Python.h>
with extern "C"
Not sure I am convinced yet that it is a fix, but since NumPy is happy, I don't mind just putting it in :). Do you need a backport of this because the real fix in Python is slower to backport? |
Seems reasonable. NumPy 2.2 supports 3.10 - 3.13, that is a lot of Python releases to rely on. |
This exposed a small latent bug in CPython
(python/cpython#127772), but it's probably not a good practice in general to wrap other code's headers with extern guards.