8000 bpo-43795: Don't list private names in the limited API (GH-26740) · python/cpython@7fd4010 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7fd4010

Browse files
bpo-43795: Don't list private names in the limited API (GH-26740)
* Remove struct _node from the stable ABI list This struct was removed along with the old parser in Python 3.9 (PEP 617) * Stable ABI list: Use the public name "PyFrameObject" rather than "_frame" * Ensure limited API doesn't contain private names Names prefixed by an underscore are private by definition. * Add a blurb (cherry picked from commit 7cad9cb) Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent 41c2a4a commit 7fd4010

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

Doc/data/stable_abi.dat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function,PyFloat_GetInfo,3.2,
272272
function,PyFloat_GetMax,3.2,
273273
function,PyFloat_GetMin,3.2,
274274
var,PyFloat_Type,3.2,
275+
type,PyFrameObject,3.2,
275276
function,PyFrame_GetCode,3.10,
276277
function,PyFrame_GetLineNumber,3.10,
277278
function,PyFrozenSet_New,3.2,
@@ -825,8 +826,6 @@ function,Py_XNewRef,3.10,
825826
type,Py_intptr_t,3.2,
826827
type,Py_ssize_t,3.2,
827828
type,Py_uintptr_t,3.2,
828-
type,_frame,3.2,
829-
type,_node,3.2,
830829
type,allocfunc,3.2,
831830
type,binaryfunc,3.2,
832831
type,descrgetfunc,3.2,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The list in :ref:`stable-abi-list` now shows the public name
2+
:c:struct:`PyFrameObject` rather than ``_frame``. The non-existing
3+
entry ``_node`` no longer appears in the list.

Misc/stable_abi.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ struct PyThreadState
3838
added 3.2
3939
struct PyInterpreterState
4040
added 3.2
41-
struct _frame
41+
struct PyFrameObject
4242
added 3.2
4343
struct symtable
4444
added 3.2
45-
struct _node
46-
added 3.2
4745
struct PyWeakReference
4846
added 3.2
4947
struct PyLongObject

Tools/scripts/stable_abi.py

+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,16 @@ def gcc_get_limited_api_definitions(headers):
492492
)
493493
return stable_data | stable_exported_data | stable_functions
494494

495+
def check_private_names(manifest):
496+
"""Ensure limited API doesn't contain private names
497+
498+
Names prefixed by an underscore are private by definition.
499+
"""
500+
for name, item in manifest.contents.items():
501+
if name.startswith('_') and not item.abi_only:
502+
raise ValueError(
503+
f'`{name}` is private (underscore-prefixed) and should be '
504+
+ 'removed from the stable ABI list or or marked `abi_only`')
495505

496506
def main():
497507
parser = argparse.ArgumentParser(
@@ -557,6 +567,8 @@ def main():
557567
with args.file.open() as file:
558568
manifest = parse_manifest(file)
559569

570+
check_private_names(manifest)
571+
560572
# Remember results of all actions (as booleans).
561573
# At the end we'll check that at least one action was run,
562574
# and also fail if any are false.

0 commit comments

Comments
 (0)
0