summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2021-06-16 09:22:36 (GMT)
committerGitHub <noreply@github.com>2021-06-16 09:22:36 (GMT)
commit7cad9cb51bdae2144cbab330f13a607ba3471742 (patch)
treed53aae128e414165484a9590c7bfb2beb4b1e619
parent741b8ae1cfc507902eb57e20f003487af13e40c0 (diff)
downloadcpython-7cad9cb51bdae2144cbab330f13a607ba3471742.zip
cpython-7cad9cb51bdae2144cbab330f13a607ba3471742.tar.gz
cpython-7cad9cb51bdae2144cbab330f13a607ba3471742.tar.bz2
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
-rw-r--r--Doc/data/stable_abi.dat3
-rw-r--r--Misc/NEWS.d/next/C API/2021-06-15-16-28-18.bpo-43795.fy0AXK.rst3
-rw-r--r--Misc/stable_abi.txt4
-rwxr-xr-xTools/scripts/stable_abi.py12
4 files changed, 17 insertions, 5 deletions
diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat
index 50207ac..5f4955b 100644
--- a/Doc/data/stable_abi.dat
+++ b/Doc/data/stable_abi.dat
@@ -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,
@@ -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,
diff --git a/Misc/NEWS.d/next/C API/2021-06-15-16-28-18.bpo-43795.fy0AXK.rst b/Misc/NEWS.d/next/C API/2021-06-15-16-28-18.bpo-43795.fy0AXK.rst
new file mode 100644
index 0000000..8d029a0
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2021-06-15-16-28-18.bpo-43795.fy0AXK.rst
@@ -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.
diff --git a/Misc/stable_abi.txt b/Misc/stable_abi.txt
index adee1a9..168e81d 100644
--- a/Misc/stable_abi.txt
+++ b/Misc/stable_abi.txt
@@ -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
diff --git a/Tools/scripts/stable_abi.py b/Tools/scripts/stable_abi.py
index 2ba5b66..b7fd2c8 100755
--- a/Tools/scripts/stable_abi.py
+++ b/Tools/scripts/stable_abi.py
@@ -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(
@@ -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.