summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2022-08-17 11:48:43 (GMT)
committerGitHub <noreply@github.com>2022-08-17 11:48:43 (GMT)
commit0f2b469ce1a6f123ad9e151b1771651b3e1d2de6 (patch)
tree6b11c45f2eaa658bb8e6db56cd92b41435edcbae /Modules/_testcapimodule.c
parent7276ca25f5f1440aa4d025350d3de15141854dde (diff)
downloadcpython-0f2b469ce1a6f123ad9e151b1771651b3e1d2de6.zip
cpython-0f2b469ce1a6f123ad9e151b1771651b3e1d2de6.tar.gz
cpython-0f2b469ce1a6f123ad9e151b1771651b3e1d2de6.tar.bz2
gh-95991: Add some infrastructure for testing Limited API in _testcapi (GH-95992)
- Limited API needs to be enabled per source file - Some builds don't support Limited API, so Limited API tests must be skipped on those builds (currently this is `Py_TRACE_REFS`, but that may change.) - `Py_LIMITED_API` must be defined before `<Python.h>` is included. This puts the hoop-jumping in `testcapi/parts.h`, so individual test files can be relatively simple. (Currently that's only `vectorcall_limited.c`, imagine more.)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 8d9a0c1..2d4c73c 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -6544,9 +6544,6 @@ PyInit__testcapi(void)
if (_PyTestCapi_Init_Vectorcall(m) < 0) {
return NULL;
}
- if (_PyTestCapi_Init_VectorcallLimited(m) < 0) {
- return NULL;
- }
if (_PyTestCapi_Init_Heaptype(m) < 0) {
return NULL;
}
@@ -6554,6 +6551,15 @@ PyInit__testcapi(void)
return NULL;
}
+#ifndef LIMITED_API_AVAILABLE
+ PyModule_AddObjectRef(m, "LIMITED_API_AVAILABLE", Py_False);
+#else
+ PyModule_AddObjectRef(m, "LIMITED_API_AVAILABLE", Py_True);
+ if (_PyTestCapi_Init_VectorcallLimited(m) < 0) {
+ return NULL;
+ }
+#endif
+
PyState_AddModule(m, &_testcapimodule);
return m;
}