Skip to content

gh-155561: Use PySlot API in Modules/_testlimitedcapi.c - #155693

Open
vstinner wants to merge 3 commits into
python:mainfrom
vstinner:limited_pyslot
Open

gh-155561: Use PySlot API in Modules/_testlimitedcapi.c#155693
vstinner wants to merge 3 commits into
python:mainfrom
vstinner:limited_pyslot

Conversation

@vstinner

@vstinner vstinner commented Aug 13, 2026

Copy link
Copy Markdown
Member

@vstinner

Copy link
Copy Markdown
Member Author

I hesitated to keep PyMethodDef and PyModuleDef code path when the Py_GIL_DISABLED macro is not defined, but this API is already tested by Modules/xxlimited_3_13.c. IMO it's better and simpler to use PySlot in both case (if Py_GIL_DISABLED is defined or not).

cc @encukou

Comment thread Modules/_testlimitedcapi.c
@vstinner

Copy link
Copy Markdown
Member Author

Oh. The build fails on WASI because Modules/config.c refers to PyModExport__testlimitedcapi() which doesn't exist.

wasm-ld: error: Modules/config.o: undefined symbol: PyInit__testlimitedcapi

and

error: undefined symbol: PyInit__testlimitedcapi (referenced by root reference (e.g. compiled C/C++ code))

Modules/config.c is generated Modules/config.c.in by Modules/makesetup.

I tried adding PyInit__testlimitedcapi() by calling PyModule_FromSlotsAndSpec() with NULL spec, but this function does crash. The spec argument must be non-NULL.

// Provide a PyInit function for Modules/config.c when _testlimitedcapi 
// extension module is built as a built-in module (ex: on WASI and Emscripten).
PyMODINIT_FUNC      
PyInit__testlimitedcapi(void)
{      
    return PyModule_FromSlotsAndSpec(_testlimitedcapimodule_slots, NULL);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants