@@ -229,12 +229,24 @@ There are three ways strings and buffers can be converted to C:
229229Numbers
230230-------
231231
232+ These formats allow representing Python numbers or single characters as C numbers.
233+ Formats that require :class: `int `, :class: `float ` or :class: `complex ` can
234+ also use the corresponding special methods :meth: `~object.__index__ `,
235+ :meth: `~object.__float__ ` or :meth: `~object.__complex__ ` to convert
236+ the Python object to the required type.
237+
238+ For signed integer formats, :exc: `OverflowError ` is raised if the value
239+ is out of range for the C type.
240+ For unsigned integer formats, no range checking is done --- the
241+ most significant bits are silently truncated when the receiving field is too
242+ small to receive the value.
243+
232244``b `` (:class: `int `) [unsigned char]
233- Convert a nonnegative Python integer to an unsigned tiny int , stored in a C
245+ Convert a nonnegative Python integer to an unsigned tiny integer , stored in a C
234246 :c:expr: `unsigned char `.
235247
236248``B `` (:class: `int `) [unsigned char]
237- Convert a Python integer to a tiny int without overflow checking, stored in a C
249+ Convert a Python integer to a tiny integer without overflow checking, stored in a C
238250 :c:expr: `unsigned char `.
239251
240252``h `` (:class: `int `) [short int]
@@ -307,7 +319,7 @@ Other objects
307319
308320.. _o_ampersand :
309321
310- ``O& `` (object) [*converter *, *anything *]
322+ ``O& `` (object) [*converter *, *address *]
311323 Convert a Python object to a C variable through a *converter * function. This
312324 takes two arguments: the first is a function, the second is the address of a C
313325 variable (of arbitrary type), converted to :c:expr: `void * `. The *converter *
@@ -321,14 +333,20 @@ Other objects
321333 the conversion has failed. When the conversion fails, the *converter * function
322334 should raise an exception and leave the content of *address * unmodified.
323335
324- If the *converter * returns ``Py_CLEANUP_SUPPORTED ``, it may get called a
336+ .. c :macro :: Py_CLEANUP_SUPPORTED
337+ :no-typesetting:
338+
339+ If the *converter * returns :c:macro: `!Py_CLEANUP_SUPPORTED `, it may get called a
325340 second time if the argument parsing eventually fails, giving the converter a
326341 chance to release any memory that it had already allocated. In this second
327342 call, the *object * parameter will be ``NULL ``; *address * will have the same value
328343 as in the original call.
329344
345+ Examples of converters: :c:func: `PyUnicode_FSConverter ` and
346+ :c:func: `PyUnicode_FSDecoder `.
347+
330348 .. versionchanged :: 3.1
331- `` Py_CLEANUP_SUPPORTED ` ` was added.
349+ :c:macro: ` ! Py_CLEANUP_SUPPORTED ` was added.
332350
333351``p `` (:class: `bool `) [int]
334352 Tests the value passed in for truth (a boolean **p **\ redicate) and converts
@@ -344,12 +362,6 @@ Other objects
344362 in *items *. The C arguments must correspond to the individual format units in
345363 *items *. Format units for sequences may be nested.
346364
347- It is possible to pass "long" integers (integers whose value exceeds the
348- platform's :c:macro: `LONG_MAX `) however no proper range checking is done --- the
349- most significant bits are silently truncated when the receiving field is too
350- small to receive the value (actually, the semantics are inherited from downcasts
351- in C --- your mileage may vary).
352-
353365A few other characters have a meaning in a format string. These may not occur
354366inside nested parentheses. They are:
355367
0 commit comments