@@ -241,9 +241,11 @@ the Python object to the required type.
241241
242242For signed integer formats, :exc: `OverflowError ` is raised if the value
243243is out of range for the C type.
244- For unsigned integer formats, no range checking is done --- the
244+ For unsigned integer formats, the
245245most significant bits are silently truncated when the receiving field is too
246- small to receive the value.
246+ small to receive the value, and :exc: `DeprecationWarning ` is emitted when
247+ the value is larger than the maximal value for the C type or less than
248+ the minimal value for the corresponding signed integer type of the same size.
247249
248250``b `` (:class: `int `) [unsigned char]
249251 Convert a nonnegative Python integer to an unsigned tiny integer, stored in a C
@@ -252,27 +254,25 @@ small to receive the value.
252254``B `` (:class: `int `) [unsigned char]
253255 Convert a Python integer to a tiny integer without overflow checking, stored in a C
254256 :c:expr: `unsigned char `.
257+ Convert a Python integer to a C :c:expr: `unsigned char `.
255258
256259``h `` (:class: `int `) [short int]
257260 Convert a Python integer to a C :c:expr: `short int `.
258261
259262``H `` (:class: `int `) [unsigned short int]
260- Convert a Python integer to a C :c:expr: `unsigned short int `, without overflow
261- checking.
263+ Convert a Python integer to a C :c:expr: `unsigned short int `.
262264
263265``i `` (:class: `int `) [int]
264266 Convert a Python integer to a plain C :c:expr: `int `.
265267
266268``I `` (:class: `int `) [unsigned int]
267- Convert a Python integer to a C :c:expr: `unsigned int `, without overflow
268- checking.
269+ Convert a Python integer to a C :c:expr: `unsigned int `.
269270
270271``l `` (:class: `int `) [long int]
271272 Convert a Python integer to a C :c:expr: `long int `.
272273
273274``k `` (:class: `int `) [unsigned long]
274- Convert a Python integer to a C :c:expr: `unsigned long ` without
275- overflow checking.
275+ Convert a Python integer to a C :c:expr: `unsigned long `.
276276
277277 .. versionchanged :: 3.14
278278 Use :meth: `~object.__index__ ` if available.
@@ -281,8 +281,7 @@ small to receive the value.
281281 Convert a Python integer to a C :c:expr: `long long `.
282282
283283``K `` (:class: `int `) [unsigned long long]
284- Convert a Python integer to a C :c:expr: `unsigned long long `
285- without overflow checking.
284+ Convert a Python integer to a C :c:expr: `unsigned long long `.
286285
287286 .. versionchanged :: 3.14
288287 Use :meth: `~object.__index__ ` if available.
@@ -310,6 +309,14 @@ small to receive the value.
310309``D `` (:class: `complex `) [Py_complex]
311310 Convert a Python complex number to a C :c:type: `Py_complex ` structure.
312311
312+ .. deprecated :: next
313+
314+ For unsigned integer formats ``B ``, ``H ``, ``I ``, ``k `` and ``K ``,
315+ :exc: `DeprecationWarning ` is emitted when the value is larger than
316+ the maximal value for the C type or less than the minimal value for
317+ the corresponding signed integer type of the same size.
318+
319+
313320Other objects
314321-------------
315322
@@ -686,6 +693,12 @@ Building values
686693 ``p`` (:class: `bool `) [int]
687694 Convert a C :c:expr:`int` to a Python :class:`bool` object.
688695
696+ Be aware that this format requires an ``int`` argument.
697+ Unlike most other contexts in C, variadic arguments are not coerced to
698+ a suitable type automatically.
699+ You can convert another type (for example, a pointer or a float) to a
700+ suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``.
701+
689702 .. versionadded:: 3.14
690703
691704 ``c`` (:class: `bytes ` of length 1) [char]
0 commit comments