GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-155561: Use multi-phase init for Modules/_testlimitedcapi.c by encukou · Pull Request #156052 · python/cpython

Conversation

@encukou

@encukou encukou commented Aug 19, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This is a continuation of #155693

We can't use PyModExport for modules that might be in inittab, but we can move to multi-phase init.

  • Issue: C API: Enable limited C API tests on Free Threading #155561

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
vstinner and others added 5 commits August 13, 2026 12:36
@vstinner
pythongh-155561: Use PySlot API in Modules/_testlimitedcapi.c
a11419e
@vstinner
Merge branch 'main' into limited_pyslot
37a19de
@vstinner
Add missing _PyTestLimitedCAPI_Init_Type() call
27c121d
@encukou
Use multi-phase init, but still with a PyModuleDef
bca539b
@encukou
Merge in the main branch
08e4a85
@encukou
encukou requested a review from vstinner August 19, 2026 12:39
@bedevere-app bedevere-app Bot added tests Tests in the Lib/test dir awaiting core review labels Aug 19, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Aug 19, 2026
C API: Enable limited C API tests on Free Threading #155561
Closed
@vstinner

vstinner commented Aug 31, 2026

Copy link
Copy Markdown
Member

According to CIs, building _testlimitedcapi fails on Free Threading:

./Modules/_testlimitedcapi.c:103:5: error: use of undeclared identifier 'PyModuleDef_HEAD_INIT'
  103 |     PyModuleDef_HEAD_INIT,
      |     ^~~~~~~~~~~~~~~~~~~~~
./Modules/_testlimitedcapi.c:102:27: error: variable has incomplete type 'struct PyModuleDef'
  102 | static struct PyModuleDef _testlimitedcapimodule_def = {
      |                           ^
./Include/pytypedefs.h:12:16: note: forward declaration of 'struct PyModuleDef'
   12 | typedef struct PyModuleDef PyModuleDef;
      |                ^
2 errors generated.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Aug 31, 2026
View reviewed changes
Comment thread Modules/_testlimitedcapi.c Outdated
// Use the oldest limited C API version
# define Py_LIMITED_API 0x03020000
#endif
// Need limited C API version 3.15 for PySlot

@vstinner vstinner Aug 31, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

PySlot is not used. I suppose that this comment is outdated.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
encukou added 3 commits September 3, 2026 13:06
@encukou
Restore the Py_GIL_DISABLED check
2891703
@encukou
Remove the #ifdef in .c file; rely on the one in parts.h
241876f
@encukou
Merge in the main branch
05ace4c
@encukou encukou added the skip news label Sep 3, 2026
@encukou
Add Py_MOD_GIL_NOT_USED for noGIL
009ce74
@encukou encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 3, 2026
@bedevere-bot

bedevere-bot commented Sep 3, 2026

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit 009ce74 🤖

Results will be shown at:

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

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 3, 2026
@vstinner

vstinner commented Sep 3, 2026

Copy link
Copy Markdown
Member

The Alpine Linux buildbot failure looks like a legit bug, but it's unrelated to this change:

  /usr/lib/ccache/bin/g++ -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-strict-overflow -Wsign-compare -g -Og -Wall -fPIC -I/buildbot/buildarea/pull_request.ware-alpine.nogil/build/build/test_python_92877æ/tempcwd/env/include -I/buildbot/buildarea/pull_request.ware-alpine.nogil/build/Include -I/buildbot/buildarea/pull_request.ware-alpine.nogil/build -c extension.cpp -o build/temp.linux-x86_64-cpython-316t-pydebug/extension.o -Werror -DMODULE_NAME=_testcppext_internal -DTEST_INTERNAL_C_API=1
  In file included from /buildbot/buildarea/pull_request.ware-alpine.nogil/build/Include/internal/pycore_object.h:13,
                   from /buildbot/buildarea/pull_request.ware-alpine.nogil/build/Include/internal/pycore_cell.h:5,
                   from extension.cpp:29:
  /buildbot/buildarea/pull_request.ware-alpine.nogil/build/Include/internal/pycore_interpframe.h: In function 'PyFrameObject* _PyFrame_GetFrameObject(_PyInterpreterFrame*)':
  /buildbot/buildarea/pull_request.ware-alpine.nogil/build/Include/internal/pycore_pyatomic_ft_wrappers.h:33:32: error: invalid conversion from 'void*' to 'PyFrameObject*' {aka '_frame*'} [-fpermissive]
     33 |     _Py_atomic_load_ptr_acquire(&value)
        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
        |                                |
        |                                void*
  /buildbot/buildarea/pull_request.ware-alpine.nogil/build/Include/internal/pycore_interpframe.h:348:26: note: in expansion of macro 'FT_ATOMIC_LOAD_PTR_ACQUIRE'
    348 |     PyFrameObject *res = FT_ATOMIC_LOAD_PTR_ACQUIRE(frame->frame_obj);
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  error: command '/usr/lib/ccache/bin/g++' failed with exit code 1
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 3, 2026

Copy link
Copy Markdown
Member

The Alpine Linux buildbot failure looks like a legit bug, but it's unrelated to this change:

Ah, in fact the AMD64 Alpine Linux NoGIL 3.x buildbot already fails on the main branch: I wrote PR gh-156893 to fix the issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 3, 2026

Copy link
Copy Markdown
Member

The "buildbot/AMD64 CentOS9 NoGIL PR" failure is the same as the Alpine Linux issue: test_cppext fails, so PR #156893 will fix it.

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner approved these changes Sep 3, 2026
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM.

This change doesn't build Modules/_testlimitedcapi.c with the limited C API on Free Threading yet, but it converts the module to multi-phase init which is already a good step forwards!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Sep 3, 2026
@encukou
encukou merged commit 112560e into python:main Sep 4, 2026
132 of 136 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 4, 2026
@encukou
encukou deleted the limited_pyslot branch September 4, 2026 10:35
@encukou encukou mentioned this pull request Sep 4, 2026
gh-155561: Use PySlot API in Modules/_testlimitedcapi.c #155693
Closed
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Sep 12, 2026
@encukou @vstinner @clin1234
pythongh-155561: Use multi-phase init for Modules/_testlimitedcapi.c (p…
e58d344
…ythonGH-156052)

Co-authored-by: Victor Stinner <[email protected]>
vstinner added a commit that referenced this pull request Oct 10, 2026
@vstinner @encukou
[3.15] gh-155561: Build most _testlimitedcapi files with Py_TARGET_AB…
72d25d5
…I3T (#155570) (#159144)

* gh-155561: Build most _testlimitedcapi files with Py_TARGET_ABI3T (#155570)

The following files are not build with Py_TARGET_ABI3T:

* Modules/_testlimitedcapi.c
* Modules/_testlimitedcapi/heaptype_relative.c
* Modules/_testlimitedcapi/vectorcall_limited.c

(cherry picked from commit 5dfa606)

* gh-155561: Use multi-phase init for Modules/_testlimitedcapi.c (GH-156052)

Co-authored-by: Victor Stinner <[email protected]>
(cherry picked from commit 112560e)

---------

Co-authored-by: Petr Viktorin <[email protected]>
@vstinner vstinner added the needs backport to 3.15 bugs and security fixes label Oct 13, 2026
@miss-islington-app

miss-islington-app Bot commented Oct 13, 2026

Copy link
Copy Markdown

Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Oct 13, 2026

Copy link
Copy Markdown

Sorry, @encukou, I could not cleanly backport this to 3.15 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 112560ee34a70c02baebdc11519d1f77e90ecab8 3.15
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app miss-islington-app Bot assigned encukou Oct 13, 2026
@vstinner vstinner removed the needs backport to 3.15 bugs and security fixes label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@encukou encukou

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@encukou @vstinner @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.