Skip to content

Commit 98e506a

Browse files
authored
bpo-43795: Document stable_abi.txt format and contents (GH-29956)
Also mention that removals generally aren't allowed.
1 parent 3cb357a commit 98e506a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Misc/stable_abi.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,46 @@
1010
# and PC/pythonXYstub.def
1111

1212

13+
# The current format is a simple line-based one with significant indentation.
14+
# Anything after a hash is a comment.
15+
16+
# There are these kinds of top-level "items":
17+
# - struct: A C struct. Currently this file does not distinguish between:
18+
# - opaque structs, which the Limited API only handles via pointers
19+
# (so these can change at any time)
20+
# - structs where only certain members are part of the stable ABI (e.g.
21+
# PyObject)
22+
# - structs which must not be changed at all (e.g. PyType_Slot, which is
23+
# fully defined and used in arrays)
24+
# - function: A function that must be kept available (and exported, i.e. not
25+
# converted to a macro).
26+
# - const: A simple value, defined with `#define`.
27+
# - macro: A preprocessor macro more complex than a simple `const` value.
28+
# - data: An exported object, which must continue to be available but its exact
29+
# value may change.
30+
# - typedef: A C typedef which is used in other definitions in the limited API.
31+
# Its size/layout/signature must not change.
32+
33+
# Each top-level item can have details defined below it:
34+
# - added: The version in which the item was added to the stable ABI.
35+
# - ifdef: A feature macro: the item is only available if this macro is defined
36+
# - abi_only: If present, the item is not part of the Limited API, but it *is*
37+
# part of the stable ABI. The item will not show up in user-facing docs.
38+
# Typically used for:
39+
# - private functions called by public macros, e.g. _Py_BuildValue_SizeT
40+
# - items that were part of the limited API in the past, and must remain part
41+
# of the stable ABI.
42+
# - a combination of the above (functions that were called by macros that
43+
# were public in the past)
44+
45+
# Removing items from this file is generally not allowed, and additions should
46+
# be considered with that in mind. See the devguide for exact rules:
47+
# https://devguide.python.org/c-api/#limited-api
48+
49+
# User-facing docs are at:
50+
# https://docs.python.org/3/c-api/stable.html#stable
51+
52+
1353
# Mentioned in PEP 384:
1454

1555
struct PyObject

Tools/scripts/stable_abi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def raise_error(msg):
174174
parent.abi_only = True
175175
else:
176176
raise_error(f"unknown kind {kind!r}")
177+
# When adding more, update the comment in stable_abi.txt.
177178
levels.append((entry, level))
178179
return manifest
179180

0 commit comments

Comments
 (0)