Skip to content

gh-130740: Move some stdbool.h includes after Python.h #130738

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 7 commits into from
Mar 2, 2025

Conversation

chouquette
Copy link
Contributor

@chouquette chouquette commented Mar 1, 2025

Except when "pyconfig.h" is included first, and for platform specific code such as android/emscripten

Following up from #130641 (comment)

Except when "pyconfig.h" is included first, and for platform specific
code such as android/emscripten
@picnixz
Copy link
Member

picnixz commented Mar 1, 2025

I see that the original PR didn't have an issue number but I would have been comfortable with one. We can also add a NEWS for build as some people might patch the sources (at least they would be notified of the change even if it's not an important one).

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Just to be sure, but Python.h already includes stdbool.h right? So we can just outright remove it or is there a reason not to?

@chouquette
Copy link
Contributor Author

Just to be sure, but Python.h already includes stdbool.h right? So we can just outright remove it or is there a reason not to?

It doesn't, or at least not directly

@picnixz picnixz changed the title ensure Python.h is included first in most circumstances Move stdbool.h includes after Python.h Mar 1, 2025
@picnixz picnixz changed the title Move stdbool.h includes after Python.h Move some stdbool.h includes after Python.h Mar 1, 2025
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

It doesn't, or at least not directly

Oh I thought it did. Ok then the changes look good to me. Also, it's still better to include it explicitly.


PEP-7 doesn't say which includes should come first in general; should we treat local imports before standard ones, namely:

#include "Python.h"
// include glibc or others system libs
// include pycore_*
// others?
// local includes

so I think we can merge this one, unless someone tells me "no!". Just to be sure, I'll run the build bots on it to see if it causes some compilation failure. Don't commit in the meantime.

@chouquette
Copy link
Contributor Author

I added a NEWS entry, although I used the PR number as issue as well. Let me know that's OK enough

@picnixz
Copy link
Member

picnixz commented Mar 1, 2025

I added a NEWS entry, although I used the PR number as issue as well. Let me know that's OK enough

I don't think we can do it. We need an issue. I'll create one.

@picnixz
Copy link
Member

picnixz commented Mar 1, 2025

Feel free to use this one: #130740

@picnixz picnixz changed the title Move some stdbool.h includes after Python.h gh-130740: Move some stdbool.h includes after Python.h Mar 1, 2025
@picnixz
Copy link
Member

picnixz commented Mar 1, 2025

Once you've updated the NEWS entry, I'll run the build bots (as Sam and I aren't sure which one is an issue/not an issue).

…SHR.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

You need to delete one of the two blurb entries

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I'll run the build bots so don't touch the PR, TiA!

@picnixz picnixz added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 1, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @picnixz for commit 6a6e5b1 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F130738%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 1, 2025
@picnixz picnixz self-assigned this Mar 1, 2025
@picnixz picnixz enabled auto-merge (squash) March 2, 2025 09:35
@picnixz picnixz merged commit 214562e into python:main Mar 2, 2025
42 checks passed
@picnixz
Copy link
Member

picnixz commented Mar 2, 2025

Thank you!

@picnixz picnixz added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Mar 2, 2025
@miss-islington-app
Copy link

Thanks @chouquette for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @chouquette for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @chouquette and @picnixz, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 214562ed4ddc248b007f718ed92ebcc0c3669611 3.12

@miss-islington-app
Copy link

Sorry, @chouquette and @picnixz, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 214562ed4ddc248b007f718ed92ebcc0c3669611 3.13

@bedevere-app
Copy link

bedevere-app bot commented Mar 2, 2025

GH-130756 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 Mar 2, 2025
picnixz pushed a commit to picnixz/cpython that referenced this pull request Mar 2, 2025
…hon#130738)

Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h`.
@bedevere-app
Copy link

bedevere-app bot commented Mar 2, 2025

GH-130757 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 2, 2025
picnixz added a commit that referenced this pull request Mar 3, 2025
…30738) (#130756)

gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)

Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h` (this caused some
build failures when compiling CPython with `zig cc`).

(cherry-picked from commit 214562e)

---------

Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
@chouquette chouquette deleted the postpone_stdbool branch March 3, 2025 16:59
picnixz added a commit that referenced this pull request Mar 4, 2025
…30738) (#130757)

gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)

Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h` (this caused some
build failures when compiling CPython with `zig cc`).

(cherry-picked from commit 214562e)

---------

Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
…hon#130738)

Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h`.
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.

3 participants