Skip to content

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

Merged
ndgrigorian merged 1 commit into
masterfrom
free-threaded-c-ext-test
Nov 10, 2026
Merged

ndgrigorian merged 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

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM
Thank you @ndgrigorian!

@ndgrigorian
ndgrigorian merged commit 4db4419 into master Nov 10, 2026
138 of 140 checks passed
@ndgrigorian
ndgrigorian deleted the free-threaded-c-ext-test branch November 10, 2026 17:21
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