Skip to content

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

Draft
encukou wants to merge 1 commit intopython:mainfrom
encukou:abi3t-pygildisabled
Draft

gh-146636: abi3t: Define Py_GIL_DISABLED but make sure not to use it#148142
encukou wants to merge 1 commit intopython:mainfrom
encukou:abi3t-pygildisabled

Conversation

@encukou
Copy link
Copy Markdown
Member

@encukou encukou commented Apr 5, 2026

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
8 tasks
@encukou encukou marked this pull request as draft April 5, 2026 21:38
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.

1 participant