From 031064b3b77588da294c4db4df5bc3257eac92c5 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 17 Jun 2025 13:38:25 +0200 Subject: [PATCH] gh-89488: Add warning about `Py_BuildValue("p")` needing exact `int` --- Doc/c-api/arg.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst index 49dbc8d71cce62..ab9f9c4539ae9a 100644 --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -686,6 +686,12 @@ Building values ``p`` (:class:`bool`) [int] Convert a C :c:expr:`int` to a Python :class:`bool` object. + 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``. + .. versionadded:: 3.14 ``c`` (:class:`bytes` of length 1) [char]