diff options
author | Victor Stinner <vstinner@python.org> | 2023-09-22 14:54:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-22 14:54:37 (GMT) |
commit | 09a25616a908a028b6373f9ab372d86edf064282 (patch) | |
tree | 38675294937df3ea61de15b73271ebc42339d487 /Modules/_testcapimodule.c | |
parent | c32abf1f21c4bd32abcefe4d601611b152568961 (diff) | |
download | cpython-09a25616a908a028b6373f9ab372d86edf064282.zip cpython-09a25616a908a028b6373f9ab372d86edf064282.tar.gz cpython-09a25616a908a028b6373f9ab372d86edf064282.tar.bz2 |
gh-109723: Disable Py_BUILD_CORE in _testcapi (#109727)
Make sure that the internal C API is not tested by mistake by
_testcapi.
Undefine Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE macros in
Modules/_testcapi/parts.h: move code from _testcapimodule.c.
heaptype_relative.c and vectorcall_limited.c are using the limited C
API which is incompatible with the internal C API.
Move test_long_numbits() from _testcapi to _testinternalcapi since it
uses the internal C API "pycore_long.h".
Fix Modules/_testcapi/pyatomic.c: don't include Python.h directly,
just include _testcapi/parts.h.
Ajust "make check-c-globals" for these changes.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index f356fc5..e09fd88 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5,19 +5,13 @@ * standard Python regression test, via Lib/test/test_capi.py. */ -/* This module tests the public (Include/ and Include/cpython/) C API. - The internal C API must not be used here: use _testinternalcapi for that. - - The Visual Studio projects builds _testcapi with Py_BUILD_CORE_MODULE - macro defined, but only the public C API must be tested here. */ - -#undef Py_BUILD_CORE_MODULE -#undef Py_BUILD_CORE_BUILTIN - -/* Always enable assertions */ -#undef NDEBUG +// Include parts.h first since it takes care of NDEBUG and Py_BUILD_CORE macros +// and including Python.h. +// +// Several parts of this module are broken out into files in _testcapi/. +// Include definitions from there. +#include "_testcapi/parts.h" -#include "Python.h" #include "frameobject.h" // PyFrame_New() #include "marshal.h" // PyMarshal_WriteLongToFile() @@ -29,17 +23,10 @@ # include <sys/wait.h> // W_STOPCODE #endif -#ifdef Py_BUILD_CORE -# error "_testcapi must test the public Python C API, not CPython internal C API" -#endif - #ifdef bool # error "The public headers should not include <stdbool.h>, see gh-48924" #endif -// Several parts of this module are broken out into files in _testcapi/. -// Include definitions from there. -#include "_testcapi/parts.h" #include "_testcapi/util.h" |