@@ -181,9 +181,11 @@ All integers are implemented as "long" integer objects of arbitrary size.
181181 single: PY_SSIZE_T_MAX
182182 single: OverflowError (built-in exception)
183183
184- Return a C :c:type:`Py_ssize_t` representation of the contents of *pylong*.
185- If *pylong* is greater than :const :`PY_SSIZE_T_MAX`, an :exc:`OverflowError`
186- is raised and ``-1`` will be returned.
184+ Return a C :c:type:`Py_ssize_t` representation of *pylong*. *pylong* must
185+ be an instance of :c:type:`PyLongObject`.
186+
187+ Raise :exc:`OverflowError` if the value of *pylong* is out of range for a
188+ :c:type:`Py_ssize_t`.
187189
188190
189191.. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)
@@ -192,49 +194,64 @@ All integers are implemented as "long" integer objects of arbitrary size.
192194 single: ULONG_MAX
193195 single: OverflowError (built-in exception)
194196
195- Return a C :c:type:`unsigned long` representation of the contents of *pylong*.
196- If *pylong* is greater than :const :`ULONG_MAX`, an :exc:`OverflowError` is
197- raised.
197+ Return a C :c:type:`unsigned long` representation of *pylong*. *pylong*
198+ must be an instance of :c:type:`PyLongObject`.
199+
200+ Raise :exc:`OverflowError` if the value of *pylong* is out of range for a
201+ :c:type:`unsigned long`.
198202
199203
200204.. c:function:: size_t PyLong_AsSize_t(PyObject *pylong)
201205
202- Return a :c:type: `size_t ` representation of the contents of *pylong *. If
203- *pylong * is greater than the maximum value for a :c:type: `size_t `, an
204- :exc: `OverflowError ` is raised.
206+ Return a C :c:type: `size_t ` representation of of *pylong *. *pylong * must be
207+ an instance of :c:type: `PyLongObject `.
208+
209+ Raise :exc: `OverflowError ` if the value of *pylong * is out of range for a
210+ :c:type: `size_t `.
205211
206212
207213.. c :function :: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong (PyObject *pylong)
208214
209215 .. index ::
210216 single: OverflowError (built-in exception)
211217
212- Return a C :c:type:`unsigned long long` from a Python integer. If
213- *pylong* cannot be represented as an :c:type:`unsigned long long`,
214- an :exc:`OverflowError` is raised and ``(unsigned long long)-1`` is
215- returned.
218+ Return a C :c:type:`unsigned PY_LONG_LONG` representation of of *pylong*.
219+ *pylong* must be an instance of :c:type:`PyLongObject`.
220+
221+ Raise :exc:`OverflowError` if the value of *pylong* is out of range for an
222+ :c:type:`unsigned PY_LONG_LONG`.
216223
217224 .. versionchanged:: 3.1
218225 A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`.
219226
220227
221- .. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io )
228+ .. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj )
222229
223- Return a C :c:type: `unsigned long ` from a Python integer, without checking for
224- overflow.
230+ Return a C :c:type: `unsigned long ` representation of *obj *. If *obj *
231+ is not an instance of :c:type: `PyLongObject `, first call its :meth: `__int__ `
232+ method (if present) to convert it to a :c:type:`PyLongObject`.
225233
234+ If the value of *obj* is out of range for an :c:type:`unsigned long`,
235+ return the reduction of that value modulo :const :`ULONG_MAX + 1`.
226236
227- .. c :function :: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask (PyObject *io)
228237
229- Return a C :c:type: `unsigned long long ` from a Python integer, without
230- checking for overflow.
238+ .. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *obj)
239+
240+ Return a C :c:type: `unsigned long long ` representation of *obj *. If *obj *
241+ is not an instance of :c:type: `PyLongObject `, first call its :meth: `__int__ `
242+ method (if present) to convert it to a :c:type:`PyLongObject`.
243+
244+ If the value of *obj* is out of range for an :c:type:`unsigned long long`,
245+ return the reduction of that value modulo :const :`PY_ULLONG_MAX + 1`.
231246
232247
233248.. c:function:: double PyLong_AsDouble(PyObject *pylong)
234249
235- Return a C :c:type: `double ` representation of the contents of *pylong *. If
236- *pylong * cannot be approximately represented as a :c:type: `double `, an
237- :exc: `OverflowError ` exception is raised and ``-1.0 `` will be returned.
250+ Return a C :c:type: `double ` representation of *pylong *. *pylong * must be
251+ an instance of :c:type: `PyLongObject `.
252+
253+ Raise :exc: `OverflowError ` if the value of *pylong * is out of range for a
254+ :c:type: `double `.
238255
239256
240257.. c :function :: void * PyLong_AsVoidPtr (PyObject *pylong)
0 commit comments