Skip to content

gh-89488: Add warning about Py_BuildValue("p") needing exact int #135610

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

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

encukou
Copy link
Member

@encukou encukou commented Jun 17, 2025

Comment on lines +689 to +693
Be aware that this format requires an ``int`` argument.
Unlike most other contexts in C, variadic arguments are not coerced to
a suitable type automatically.
You can convert another type (for example, a pointer or a float) to a
suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``.
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to put this inside a .. note:: directive, like the .. note:: This format does not accept bytes-like objects above?

Suggested change
Be aware that this format requires an ``int`` argument.
Unlike most other contexts in C, variadic arguments are not coerced to
a suitable type automatically.
You can convert another type (for example, a pointer or a float) to a
suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``.
.. note::
This format requires an ``int`` argument.
Unlike most other contexts in C, variadic arguments are not coerced to
a suitable type automatically.
You can convert another type (for example, a pointer or a float) to a
suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``.

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 wouldn't mind, but, I don't think this needs to be called out so prominently. An extra paragraph is already pretty noticeable.

@encukou encukou added the needs backport to 3.14 bugs and security fixes label Jun 23, 2025
@encukou encukou merged commit 6aa0826 into python:main Jun 23, 2025
33 checks passed
@miss-islington-app
Copy link

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

@encukou encukou deleted the p-docs branch June 23, 2025 10:36
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jun 23, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 23, 2025
…`int` (pythonGH-135610)

(cherry picked from commit 6aa0826)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jun 23, 2025

GH-135843 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jun 23, 2025
encukou added a commit that referenced this pull request Jun 23, 2025
… `int` (GH-135610) (GH-135843)

(cherry picked from commit 6aa0826)

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
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants