Skip to content

Declare the test C extension free-threading compatible - #2421

Open
ndgrigorian wants to merge 1 commit into
masterfrom
free-threaded-c-ext-test
Open

ndgrigorian wants to merge 1 commit into
masterfrom
free-threaded-c-ext-test

Conversation

@ndgrigorian

Copy link
Copy Markdown
Collaborator

This PR fixes the warning emitted by test_c_headers on free-threaded builds of CPython, where loading the _c_ext test extension re-enabled the GIL for the rest of the test session

RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module '_c_ext', which has not declared that it can run safely without the GIL.

_c_ext now uses multi-phase initialization and declares Py_mod_gil as Py_MOD_GIL_NOT_USED, as the py_sycl_ls C example already does, and the fixture loading it turns the RuntimeWarning into an error so that this does not regress

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?
  • If this PR is a work in progress, are you opening the PR as a draft?

_c_ext uses multi-phase init with Py_mod_gil, so loading it no longer
re-enables the GIL, and test_headers errors if it does.
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 74.963%. remained the same — free-threaded-c-ext-test into master

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

2 participants