Skip to content

gh-156870: Add common Stable ABI notes for tables of definitions - #156871

Merged
encukou merged 9 commits into
python:mainfrom
encukou:manual-stable-abi-notes
Oct 21, 2026
Merged

encukou merged 9 commits into
python:mainfrom
encukou:manual-stable-abi-notes

Conversation

@encukou

@encukou encukou commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Add two directives:

  • .. stable-abi-note:: adds a note with similar formatting as the auto-generated notes (not exact; that can be fixed in CSS which is in a different repo)
  • .. omit-stable-abi-notes:: a block in which autogenerated notes are omitted

Apply that to the tables of exceptions & iteration types.

(This PR has lots of indentation changes; hide them with ?w=1 in GitHub or -w on the Git command line.)

@read-the-docs-community

read-the-docs-community Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

@picnixz picnixz changed the title gh-156870: Ad common stable abi notes for tables of definitions gh-156870: Add common stable abi notes for tables of definitions Sep 3, 2026
@picnixz picnixz changed the title gh-156870: Add common stable abi notes for tables of definitions gh-156870: Add common Stable ABI notes for tables of definitions Sep 3, 2026

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be broken, we've lost all notes looking at the preview:

Image

Comment thread Doc/tools/extensions/c_annotations.py Outdated
# in a 'c_annotations' attribute.
ancestor = node
while ancestor:
if 'omit-stable-abi-note' not in ancestor.get(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip the note if any ancestor has 'omit-stable-abi-note'

Is this not inverted, it's skipped if it's absent?

Comment thread Doc/tools/extensions/c_annotations.py Outdated
[],
):
break
ancestor = node.parent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be ancestor.parent?

Comment thread Doc/tools/extensions/c_annotations.py
Comment thread Doc/tools/extensions/c_annotations.py Outdated
# no skip; add the annotation
annotation = _stable_abi_annotation(record)
node.insert(0, annotation)
node.setdefault("classes", []).append('ADDED-HERE')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from debugging I presume?

@encukou

encukou commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Yes, thanks to the catch. That was not the code I meant to send.
Sorry for the noise!

Comment thread Doc/c-api/exceptions.rst Outdated

These pointers are part of the :ref:`Stable ABI <stable>` since the
version in the *S.ABI* column (or since 3.2 when *S.ABI* is empty).
Exceptions marked N/A are *not* part of Stable ABI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Exceptions marked N/A are *not* part of Stable ABI.
Exceptions marked N/A are *not* part of the Stable ABI.

Comment thread Doc/c-api/iterator.rst
ancestor = ancestor.parent
else:
# no skip; add the annotation
annotation = _stable_abi_annotation(record)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach seems a bit fragile and wasteful, we already have the Stable ABI data, but we're duplicating it with hand-written tables. Can we at least assert it matches stable_abi_data?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found a good way to do the assert.

I think this automation is a good tool -- it probably prevented a bunch of mistakes -- but where it has subpar results, we shouldn't be afraid to drop it and fall bask to writing things manually, like everywhere else in the docs.

If we start seeing many "S.ABI" columns, maybe we should automate that, but I don't think we're there yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of anything either I'm afraid.

Comment thread Doc/tools/extensions/c_annotations.py
Comment thread Doc/tools/extensions/c_annotations.py Outdated
has_content = True

def run(self) -> list[nodes.Node]:
node = nodes.Element() # Anonymous container for parsing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we note use SphinxDirective.parse_content_to_nodes to simplify a little?

Comment thread Doc/tools/extensions/c_annotations.py
@encukou

encukou commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

@StanFromIreland, do you want to take a look again?

Comment thread Doc/c-api/exceptions.rst
:c:data:`PyExc_BaseExceptionGroup`.


OSError aliases

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about these, they are inconsistent now:

Image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to handle these in a follow-up: #160111

@encukou
encukou merged commit 99edd54 into python:main Oct 21, 2026
34 checks passed
@encukou
encukou deleted the manual-stable-abi-notes branch October 21, 2026 21:01
@encukou encukou added the needs backport to 3.15 bugs and security fixes label Oct 23, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 23, 2026

Copy link
Copy Markdown

GH-160539 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 23, 2026
encukou added a commit that referenced this pull request Oct 24, 2026
…ns (GH-156871) (GH-160539)

gh-156870: Add common Stable ABI notes for tables of definitions (GH-156871)
(cherry picked from commit 99edd54)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants