aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Tools/c-analyzer/c_parser/preprocessor/gcc.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-09-22 16:54:37 +0200
committerGitHub <noreply@github.com>2023-09-22 14:54:37 +0000
commit09a25616a908a028b6373f9ab372d86edf064282 (patch)
tree38675294937df3ea61de15b73271ebc42339d487 /Tools/c-analyzer/c_parser/preprocessor/gcc.py
parentc32abf1f21c4bd32abcefe4d601611b152568961 (diff)
downloadcpython-09a25616a908a028b6373f9ab372d86edf064282.tar.gz
cpython-09a25616a908a028b6373f9ab372d86edf064282.zip
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 'Tools/c-analyzer/c_parser/preprocessor/gcc.py')
-rw-r--r--Tools/c-analyzer/c_parser/preprocessor/gcc.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/Tools/c-analyzer/c_parser/preprocessor/gcc.py b/Tools/c-analyzer/c_parser/preprocessor/gcc.py
index d206ceb43a2..6ece70c77fd 100644
--- a/Tools/c-analyzer/c_parser/preprocessor/gcc.py
+++ b/Tools/c-analyzer/c_parser/preprocessor/gcc.py
@@ -3,18 +3,20 @@ import re
from . import common as _common
-# The following C files define the Py_LIMITED_API macro, and so must not be
-# built with the Py_BUILD_CORE macro defined.
-USE_LIMITED_C_API = frozenset((
+# The following C files must not built with Py_BUILD_CORE.
+FILES_WITHOUT_INTERNAL_CAPI = frozenset((
# Modules/
'_testcapimodule.c',
'_testclinic_limited.c',
'xxlimited.c',
'xxlimited_35.c',
+))
+# C files in the fhe following directories must not be built with
+# Py_BUILD_CORE.
+DIRS_WITHOUT_INTERNAL_CAPI = frozenset((
# Modules/_testcapi/
- 'heaptype_relative.c',
- 'vectorcall_limited.c',
+ '_testcapi',
))
TOOL = 'gcc'
@@ -75,7 +77,10 @@ def preprocess(filename,
filename = _normpath(filename, cwd)
postargs = POST_ARGS
- if os.path.basename(filename) not in USE_LIMITED_C_API:
+ basename = os.path.basename(filename)
+ dirname = os.path.basename(os.path.dirname(filename))
+ if (basename not in FILES_WITHOUT_INTERNAL_CAPI
+ and dirname not in DIRS_WITHOUT_INTERNAL_CAPI):
postargs += ('-DPy_BUILD_CORE=1',)
text = _common.preprocess(