Skip to content

Commit 70e0699

Browse files
committed
Export the existing frame-locals C API on Windows
Explicitly include PyFrame_GetLocals as a non-Stable ABI compatibility exception. Preserve the Stable ABI inventory, source/compiled checks, existing implementation and canonical tests; the generated Windows export table gains exactly this one function. Assisted-by: Codex:model-version-unavailable
1 parent aee116f commit 70e0699

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎capi-exports.def‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
; Generated by scripts/generate_capi_exports.py; do not edit by hand.
22
; CPython v3.15.0rc3: 8a8eb0b90d40f0e03f8252e9f73cad156e1caca8
33
; Misc/stable_abi.toml SHA-256: eab726f2482c71e67a23ea04aaa9c5a11d565bee4472320f813262f273c1e966
4-
; Only implemented stable-ABI functions/data, including ABI-only names.
4+
; Implemented Stable ABI functions/data, including ABI-only names.
5+
; Non-Stable ABI compatibility export: PyFrame_GetLocals.
56
EXPORTS
67
PyABIInfo_Check
78
PyAIter_Check
@@ -192,6 +193,7 @@ EXPORTS
192193
PyFloat_GetMin
193194
PyFrame_GetCode
194195
PyFrame_GetLineNumber
196+
PyFrame_GetLocals
195197
PyFrozenSet_New
196198
PyGC_Collect
197199
PyGC_Disable

‎scripts/generate_capi_exports.py‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""Generate Windows C API exports from implemented stable-ABI definitions.
1+
"""Generate Windows C API exports from implemented definitions.
2+
3+
Exports are Stable ABI definitions plus the explicitly listed existing
4+
non-Stable ABI compatibility function.
25
36
Maintenance dependencies: Python 3.11+, Git, the pinned CPython checkout, and
47
RustPython source. Compiled verification additionally needs GNU nm and a matching
@@ -18,6 +21,9 @@
1821
MANIFEST_SHA256 = "eab726f2482c71e67a23ea04aaa9c5a11d565bee4472320f813262f273c1e966"
1922
EXPORT_ATTR = "#[unsafe(no_mangle)]"
2023
ITEM_PREFIX = r"#\[unsafe\(no_mangle\)\](?:\s*#\[[^\n]*\])*\s*pub\s+"
24+
# Already implemented and exported on Unix; needed for Windows frame access.
25+
# This function is not part of CPython's Stable ABI.
26+
NON_STABLE_COMPATIBILITY_EXPORTS = {"PyFrame_GetLocals": "function"}
2127

2228

2329
def fail(message):
@@ -125,11 +131,19 @@ def generate(args):
125131
if "ifdef" in entry:
126132
fail(f"Review target condition for {name}: {entry['ifdef']}")
127133
exports[name] = kind
134+
stable_count = len(exports)
135+
for name, kind in NON_STABLE_COMPATIBILITY_EXPORTS.items():
136+
if source.get(name) != kind:
137+
fail(f"Missing or mismatched compatibility definition: {name}")
138+
if name in manifest.get(kind, {}):
139+
fail(f"Remove the now-stable compatibility exception for {name}")
140+
exports[name] = kind
128141
contents = (
129142
"; Generated by scripts/generate_capi_exports.py; do not edit by hand.\n"
130143
f"; CPython v3.15.0rc3: {CPYTHON_REVISION}\n"
131144
f"; Misc/stable_abi.toml SHA-256: {MANIFEST_SHA256}\n"
132-
"; Only implemented stable-ABI functions/data, including ABI-only names.\n"
145+
"; Implemented Stable ABI functions/data, including ABI-only names.\n"
146+
"; Non-Stable ABI compatibility export: PyFrame_GetLocals.\n"
133147
"EXPORTS\n"
134148
) + "".join(
135149
f" {name}{' DATA' if kind == 'data' else ''}\n"
@@ -141,7 +155,8 @@ def generate(args):
141155
else:
142156
args.output.write_text(contents)
143157
print(
144-
f"{len(source)} source exports; {len(exports)} stable Windows exports "
158+
f"{len(source)} source exports; {len(exports)} Windows exports "
159+
f"({stable_count} Stable ABI, {len(NON_STABLE_COMPATIBILITY_EXPORTS)} non-Stable ABI); "
145160
f"({sum(kind == 'data' for kind in exports.values())} data)"
146161
)
147162

0 commit comments

Comments
 (0)