Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-43795: Don't list private names in the limited API #26740

Merged
merged 4 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Doc/data/stable_abi.dat
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ function,PyFloat_GetInfo,3.2,
function,PyFloat_GetMax,3.2,
function,PyFloat_GetMin,3.2,
var,PyFloat_Type,3.2,
type,PyFrameObject,3.2,
function,PyFrame_GetCode,3.10,
function,PyFrame_GetLineNumber,3.10,
function,PyFrozenSet_New,3.2,
Expand Down Expand Up @@ -825,8 +826,6 @@ function,Py_XNewRef,3.10,
type,Py_intptr_t,3.2,
type,Py_ssize_t,3.2,
type,Py_uintptr_t,3.2,
type,_frame,3.2,
type,_node,3.2,
type,allocfunc,3.2,
type,binaryfunc,3.2,
type,descrgetfunc,3.2,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The list in :ref:`stable-abi-list` now shows the public name
:c:struct:`PyFrameObject` rather than ``_frame``. The non-existing
entry ``_node`` no longer appears in the list.
4 changes: 1 addition & 3 deletions Misc/stable_abi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ struct PyThreadState
added 3.2
struct PyInterpreterState
added 3.2
struct _frame
struct PyFrameObject
added 3.2
struct symtable
added 3.2
struct _node
added 3.2
struct PyWeakReference
added 3.2
struct PyLongObject
Expand Down
12 changes: 12 additions & 0 deletions Tools/scripts/stable_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,16 @@ def gcc_get_limited_api_definitions(headers):
)
return stable_data | stable_exported_data | stable_functions

def check_private_names(manifest):
"""Ensure limited API doesn't contain private names

Names prefixed by an underscore are private by definition.
"""
for name, item in manifest.contents.items():
if name.startswith('_') and not item.abi_only:
raise ValueError(
f'`{name}` is private (underscore-prefixed) and should be '
+ 'removed from the stable ABI list or or marked `abi_only`')

def main():
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -557,6 +567,8 @@ def main():
with args.file.open() as file:
manifest = parse_manifest(file)

check_private_names(manifest)

# Remember results of all actions (as booleans).
# At the end we'll check that at least one action was run,
# and also fail if any are false.
Expand Down