gh-146636: abi3t: Define Py_GIL_DISABLED but do not to use it by encukou · Pull Request #148142 · python/cpython · GitHub
Skip to content

gh-146636: abi3t: Define Py_GIL_DISABLED but do not to use it - #148142

Merged
encukou merged 2 commits into
python:mainfrom
encukou:abi3t-pygildisabled
Apr 7, 2026
Merged

encukou merged 2 commits into
python:mainfrom
encukou:abi3t-pygildisabled

Conversation

@encukou

@encukou encukou commented Apr 5, 2026

Copy link
Copy Markdown
Member

When compiling for abi3t, define Py_GIL_DISABLED, so that users who check it to enable additional locking aren't broken.

But also add a test that Python headers themselves don't use Py_GIL_DISABLED, since abi3 and abi3t ought to be the same except the _Py_OPAQUE_PYOBJECT differences.
This is done using the GCC-only poison pragma, which tells the compiler/preprocessor to error if it ever sees the identifier after the pragma.
This did require rewriting some preprocessor conditions -- #if defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED) needs to be split into two lines, as the poisoning doesn't honour short-circuiting.
For _Py_IsOwnedByCurrentThread & supporting functions I opted to move them to a cpython/ header, as they're rather self-contained.

…se it

When compiling for abi3t, define Py_GIL_DISABLED, so that users who
check it to enable additional locking aren't broken.

But also add a test that Python headers themselves don't use
Py_GIL_DISABLED -- abi3 and abi3t ought to be the same except
the _Py_OPAQUE_PYOBJECT differences.
This is done using the GCC-only poison pragma.
This did require rewriting some preprocessor conditions, and
moving _Py_IsOwnedByCurrentThread & supporting functions
to a cpython/ header.
@bedevere-app bedevere-app Bot mentioned this pull request Apr 5, 2026
9 tasks
@encukou
encukou marked this pull request as draft April 5, 2026 21:38
@encukou
encukou marked this pull request as ready for review April 6, 2026 08:55
@encukou encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 6, 2026
@bedevere-bot

Copy link
Copy Markdown

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 6, 2026
@encukou encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 7, 2026
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit 1cd72a7 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F148142%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 Apr 7, 2026
@encukou encukou changed the title gh-146636: abi3t: Define Py_GIL_DISABLED but make sure not to use it gh-146636: abi3t: Define Py_GIL_DISABLED but do not to use it Apr 7, 2026
@encukou

encukou commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

Some paths still use Py_GIL_DISABLED.
I'd like to merge this for today's alpha without the check; I'll add the check later.

@encukou
encukou merged commit fbc1a5b into python:main Apr 7, 2026
77 of 86 checks passed
@encukou
encukou deleted the abi3t-pygildisabled branch April 7, 2026 07:06
@bedevere-bot

Copy link
Copy Markdown

ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
…honGH-148142)

When compiling for abi3t, define Py_GIL_DISABLED, so that users who
check it to enable additional locking aren't broken.

But also avoid using Py_GIL_DISABLED in Python headers themselves
-- abi3 and abi3t ought to be the same except
the _Py_OPAQUE_PYOBJECT differences.

A check for this is coming in a later PR.
It will require rewriting some preprocessor conditions, some of these
changes are included in this PR.
For _Py_IsOwnedByCurrentThread & supporting functions
I opted to move them to a cpython/ header, as they're rather self-contained.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

2 participants