Skip to content

PyTuple_SetItem documentation doesn't warn about refcount requirements #117283

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

Closed
Yhg1s opened this issue Mar 27, 2024 · 1 comment
Closed

PyTuple_SetItem documentation doesn't warn about refcount requirements #117283

Yhg1s opened this issue Mar 27, 2024 · 1 comment
Labels
docs Documentation in the Doc dir topic-C-API

Comments

@Yhg1s
Copy link
Member

Yhg1s commented Mar 27, 2024

The PyTuple_SetItem() function (correctly) raises a SystemError when used on a tuple whose refcount isn't 1. The PyTuple_SET_ITEM() macro doesn't have any checks on the refcount, but it's still really bad to use it on a tuple that already in use. However, the documentation doesn't mention this requirement. It could probably use a bright red flashing box with waving hands and a shouting man telling you not to use it on anything but newly created tuples.

By contrast, the docs for the _PyTuple_Resize() function, which also raises SystemErrow when used on a tuple whose refcount isn't 1, does warn about the refcount requirement, although it isn't clear how hard a requirement it is. (It says "should not be used" rather than "cannot be used".)

Linked PRs

@Yhg1s Yhg1s added the docs Documentation in the Doc dir label Mar 27, 2024
@savannahostrowski
Copy link
Member

If no one is looking at this, I'd love to open a PR to update the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-C-API
Projects
None yet
Development

No branches or pull requests

4 participants