Skip to content

Commit 61092a9

Browse files
authored
bpo-43690: stable_abi.py no longer parses macros (GH-25136)
The stable_abi.py script no longer parse macros. Macro targets can be static inline functions which are not part of the stable ABI, only part of the limited C API. Run "make regen-limited-abi" to exclude PyType_HasFeature from Doc/data/stable_abi.dat.
1 parent baf10da commit 61092a9

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

Doc/data/stable_abi.dat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ PyType_GetFlags
616616
PyType_GetModule
617617
PyType_GetModuleState
618618
PyType_GetSlot
619-
PyType_HasFeature
620619
PyType_IsSubtype
621620
PyType_Modified
622621
PyType_Ready

Tools/scripts/stable_abi.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,10 @@ def generate_limited_api_symbols(args):
112112
stable_data, stable_exported_data, stable_functions = get_limited_api_definitions(
113113
headers
114114
)
115-
macros = get_limited_api_macros(headers)
116115

117116
stable_symbols = {
118117
symbol
119-
for symbol in (stable_functions | stable_exported_data | stable_data | macros)
118+
for symbol in (stable_functions | stable_exported_data | stable_data)
120119
if symbol.startswith("Py") and symbol in available_symbols
121120
}
122121
with open(args.output_file, "w") as output_file:
@@ -128,36 +127,6 @@ def generate_limited_api_symbols(args):
128127
output_file.write(f"{symbol}\n")
129128

130129

131-
def get_limited_api_macros(headers):
132-
"""Run the preprocesor over all the header files in "Include" setting
133-
"-DPy_LIMITED_API" to the correct value for the running version of the interpreter
134-
and extracting all macro definitions (via adding -dM to the compiler arguments).
135-
"""
136-
137-
preprocesor_output_with_macros = subprocess.check_output(
138-
sysconfig.get_config_var("CC").split()
139-
+ [
140-
# Prevent the expansion of the exported macros so we can capture them later
141-
"-DSIZEOF_WCHAR_T=4", # The actual value is not important
142-
f"-DPy_LIMITED_API={sys.version_info.major << 24 | sys.version_info.minor << 16}",
143-
"-I.",
144-
"-I./Include",
145-
"-dM",
146-
"-E",
147-
]
148-
+ [str(file) for file in headers],
149-
text=True,
150-
stderr=subprocess.DEVNULL,
151-
)
152-
153-
return {
154-
target
155-
for _, target in re.findall(
156-
r"#define (\w+)\s*(?:\(.*?\))?\s+(\w+)", preprocesor_output_with_macros
157-
)
158-
}
159-
160-
161130
def get_limited_api_definitions(headers):
162131
"""Run the preprocesor over all the header files in "Include" setting
163132
"-DPy_LIMITED_API" to the correct value for the running version of the interpreter.

0 commit comments

Comments
 (0)