@@ -229,12 +229,24 @@ There are three ways strings and buffers can be converted to C:
229
229
Numbers
230
230
-------
231
231
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
+
232
244
``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
234
246
:c:expr: `unsigned char `.
235
247
236
248
``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
238
250
:c:expr: `unsigned char `.
239
251
240
252
``h `` (:class: `int `) [short int]
@@ -344,12 +356,6 @@ Other objects
344
356
in *items *. The C arguments must correspond to the individual format units in
345
357
*items *. Format units for sequences may be nested.
346
358
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
-
353
359
A few other characters have a meaning in a format string. These may not occur
354
360
inside nested parentheses. They are:
355
361
0 commit comments