forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-95991: Add some infrastructure for testing Limited API in _t…
…estcapi - 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.)
- Loading branch information
Showing
5 changed files
with
55 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
#ifndef Py_TESTCAPI_PARTS_H | ||
#define Py_TESTCAPI_PARTS_H | ||
|
||
#include "pyconfig.h" // for Py_TRACE_REFS | ||
|
||
// Figure out if Limited API is available for this build. If it isn't we won't | ||
// build tests for it. | ||
// Currently, only Py_TRACE_REFS disables Limited API. | ||
#ifdef Py_TRACE_REFS | ||
#undef LIMITED_API_AVAILABLE | ||
#else | ||
#define LIMITED_API_AVAILABLE 1 | ||
#endif | ||
|
||
// Always enable assertions | ||
#undef NDEBUG | ||
|
||
#if !defined(LIMITED_API_AVAILABLE) && defined(Py_LIMITED_API) | ||
// Limited API being unavailable means that with Py_LIMITED_API defined | ||
// we can't even include Python.h. | ||
// Do nothing; the .c file that defined Py_LIMITED_API should also do nothing. | ||
|
||
#else | ||
|
||
#include "Python.h" | ||
|
||
/* Always enable assertions */ | ||
#undef NDEBUG | ||
|
||
int _PyTestCapi_Init_Vectorcall(PyObject *module); | ||
int _PyTestCapi_Init_VectorcallLimited(PyObject *module); | ||
int _PyTestCapi_Init_Heaptype(PyObject *module); | ||
int _PyTestCapi_Init_Unicode(PyObject *module); | ||
|
||
#ifdef LIMITED_API_AVAILABLE | ||
int _PyTestCapi_Init_VectorcallLimited(PyObject *module); | ||
#endif // LIMITED_API_AVAILABLE | ||
|
||
#endif | ||
#endif // Py_TESTCAPI_PARTS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters