Skip to content

gh-144473: Add "steal" term to glossary; clarify "stealing" on error#144474

Open
encukou wants to merge 1 commit intopython:mainfrom
encukou:steal-doc
Open

gh-144473: Add "steal" term to glossary; clarify "stealing" on error#144474
encukou wants to merge 1 commit intopython:mainfrom
encukou:steal-doc

Conversation

@encukou
Copy link
Member

@encukou encukou commented Feb 4, 2026

With one exception, all "stealing" functions also steal on error,
but it makes sense to note this in each case.

steal
In Python's C API, "*stealing*" an argument means that ownership of the
argument is transferred to the called function.
Copy link
Member

Choose a reason for hiding this comment

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

You may add something like: "The caller must not use that reference after the call".

Copy link
Member Author

Choose a reason for hiding this comment

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

I added that to the api-refcountdetails that's linked below. Do you think it needs to be here as well?

Copy link
Member

Choose a reason for hiding this comment

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

Do you think it needs to be here as well?

Yes, IMO it's worth it to repeat it here.

This function ":term:`steals <steal>`" a reference to *item*,
even on error.
On success, it discards a reference to an item already in the list
at the affected position (unless it was NULL).
Copy link
Member

Choose a reason for hiding this comment

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

NULL should be in a code block:

Suggested change
at the affected position (unless it was NULL).
at the affected position (unless it was ``NULL``).

created, the old reference to *bytes* will still be discarded and the value
of *\*bytes* will be set to ``NULL``; the appropriate exception will be set.
appended to *bytes*; the caller will own the new reference.
The reference to the old value of *bytes* will be ":term:`stolen <steal>`".
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a huge fan of putting "steal(s)" in quotations. If the user is confused about the term, then they can just click it to go to the glossary. Otherwise, the user knows the term, so it shouldn't be in scare quotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news topic-C-API

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants