Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 53 additions & 58 deletions Modules/_testlimitedcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,117 @@
* Test the limited C API.
*
* The 'test_*' functions exported by this module are run as part of the
* standard Python regression test, via Lib/test/test_capi.py.
* standard Python regression test, via Lib/test/test_capi/test_misc.py.
*/

#include "pyconfig.h" // Py_GIL_DISABLED

#ifdef Py_GIL_DISABLED
// Cannot test the limited C API
#else
// Use the oldest limited C API version
# define Py_LIMITED_API 0x03020000
#endif
// Need limited C API version 3.15 for PySlot
#define Py_LIMITED_API 0x030f0000

#include "_testlimitedcapi/parts.h"

static PyMethodDef TestMethods[] = {
{NULL, NULL} /* sentinel */
};

static struct PyModuleDef _testlimitedcapimodule = {
PyModuleDef_HEAD_INIT,
.m_name = "_testlimitedcapi",
.m_size = 0,
.m_methods = TestMethods,
};

PyMODINIT_FUNC
PyInit__testlimitedcapi(void)
static int
module_exec(PyObject *mod)
{
PyObject *mod = PyModule_Create(&_testlimitedcapimodule);
if (mod == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
#endif

if (_PyTestLimitedCAPI_Init_Abstract(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_ByteArray(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Bytes(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Capsule(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Codec(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Complex(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Dict(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Eval(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Float(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_HeaptypeRelative(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Import(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_List(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Long(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Object(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_PyOS(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Set(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Slots(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Sys(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_ThreadState(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Tuple(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Unicode(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_VectorcallLimited(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Version(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_File(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Weakref(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Run(mod) < 0) {
return NULL;
return -1;
}
if (_PyTestLimitedCAPI_Init_Type(mod) < 0) {
return NULL;
return -1;
}
return mod;
return 0;
}

PyABIInfo_VAR(abi_info);

static struct PyModuleDef _testlimitedcapimodule_def = {

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

storage size of ‘_testlimitedcapimodule_def’ isn’t known

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

variable ‘_testlimitedcapimodule_def’ has initializer but incomplete type

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

storage size of ‘_testlimitedcapimodule_def’ isn’t known

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

variable ‘_testlimitedcapimodule_def’ has initializer but incomplete type

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

initializer is not a constant [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

'_testlimitedcapimodule_def' uses undefined struct 'PyModuleDef' [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

initializer is not a constant [C:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

'_testlimitedcapimodule_def' uses undefined struct 'PyModuleDef' [C:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, tail-call)

initializer is not a constant [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 102 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, tail-call)

'_testlimitedcapimodule_def' uses undefined struct 'PyModuleDef' [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]
PyModuleDef_HEAD_INIT,

Check warning on line 103 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

excess elements in struct initializer

Check failure on line 103 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

‘PyModuleDef_HEAD_INIT’ undeclared here (not in a function); did you mean ‘PyModuleDef_Init’?

Check warning on line 103 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

excess elements in struct initializer

Check failure on line 103 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

‘PyModuleDef_HEAD_INIT’ undeclared here (not in a function); did you mean ‘PyModuleDef_Init’?

Check failure on line 103 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

'PyModuleDef_HEAD_INIT': undeclared identifier [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 103 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

'PyModuleDef_HEAD_INIT': undeclared identifier [C:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 103 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, tail-call)

'PyModuleDef_HEAD_INIT': undeclared identifier [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]
.m_name = "_testlimitedcapi",

Check warning on line 104 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

excess elements in struct initializer

Check failure on line 104 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

‘struct PyModuleDef’ has no member named ‘m_name’

Check warning on line 104 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

excess elements in struct initializer

Check failure on line 104 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

‘struct PyModuleDef’ has no member named ‘m_name’

Check failure on line 104 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

left of '.m_name' must have struct/union type [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 104 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

left of '.m_name' must have struct/union type [C:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 104 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, tail-call)

left of '.m_name' must have struct/union type [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]
.m_size = 0,

Check warning on line 105 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

excess elements in struct initializer

Check failure on line 105 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

‘struct PyModuleDef’ has no member named ‘m_size’

Check warning on line 105 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

excess elements in struct initializer

Check failure on line 105 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

‘struct PyModuleDef’ has no member named ‘m_size’

Check failure on line 105 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

left of '.m_size' must have struct/union type [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 105 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

left of '.m_size' must have struct/union type [C:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 105 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, tail-call)

left of '.m_size' must have struct/union type [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]
.m_slots = (PyModuleDef_Slot[]){

Check warning on line 106 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

excess elements in struct initializer

Check failure on line 106 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

‘struct PyModuleDef’ has no member named ‘m_slots’

Check warning on line 106 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

excess elements in struct initializer

Check failure on line 106 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

‘struct PyModuleDef’ has no member named ‘m_slots’

Check failure on line 106 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

left of '.m_slots' must have struct/union type [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 106 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

left of '.m_slots' must have struct/union type [C:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 106 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, tail-call)

left of '.m_slots' must have struct/union type [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]
{Py_mod_abi, &abi_info},
{Py_mod_exec, module_exec},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0}
}
};

Check failure on line 112 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

too many initializers [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 112 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

too many initializers [C:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check failure on line 112 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, tail-call)

too many initializers [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

PyMODINIT_FUNC
PyInit__testlimitedcapi(void)
{
return PyModuleDef_Init(&_testlimitedcapimodule_def);

Check warning on line 117 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

'function': incompatible types - from 'int *' to 'PyModuleDef *' [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check warning on line 117 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

'function': incompatible types - from 'int *' to 'PyModuleDef *' [C:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]

Check warning on line 117 in Modules/_testlimitedcapi.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, tail-call)

'function': incompatible types - from 'int *' to 'PyModuleDef *' [D:\a\cpython\cpython\PCbuild\_testlimitedcapi.vcxproj]
}
Loading