@@ -122,26 +122,29 @@ All integers are implemented as "long" integer objects of arbitrary size.
122122
123123
124124.. XXX alias PyLong_AS_LONG (for now)
125- .. c :function :: long PyLong_AsLong (PyObject *pylong )
125+ .. c :function :: long PyLong_AsLong (PyObject *obj )
126126
127127 .. index ::
128128 single: LONG_MAX
129129 single: OverflowError (built-in exception)
130130
131- Return a C :c:type:`long` representation of the contents of *pylong*. If
132- *pylong* is greater than :const :`LONG_MAX`, raise an :exc:`OverflowError`,
133- and return -1. Convert non-long objects automatically to long first,
134- and return -1 if that raises exceptions.
131+ Return a C :c:type:`long` representation of *obj*. If *obj* is not an
132+ instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method
133+ (if present) to convert it to a :c:type:`PyLongObject`.
135134
136- .. c:function:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow)
135+ Raise :exc:`OverflowError` if the value of *obj* is out of range for a
136+ :c:type:`long`.
137137
138- Return a C :c:type: `long ` representation of the contents of
139- *pylong *. If *pylong * is greater than :const: `LONG_MAX ` or less
140- than :const: `LONG_MIN `, set *\* overflow * to ``1 `` or ``-1 ``,
141- respectively, and return ``-1 ``; otherwise, set *\* overflow * to
142- ``0 ``. If any other exception occurs (for example a TypeError or
143- MemoryError), then ``-1`` will be returned and *\*overflow* will
144- be ``0``.
138+ .. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
139+
140+ Return a C :c:type: `long ` representation of *obj *. If *obj * is not an
141+ instance of :c:type: `PyLongObject `, first call its :meth: `__int__ ` method
142+ (if present) to convert it to a :c:type:`PyLongObject`.
143+
144+ If the value of *obj* is greater than :const :`LONG_MAX` or less than
145+ :const :`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, and
146+ return ``-1``; otherwise, set *\*overflow* to ``0 ``. If any other exception
147+ occurs set *\* overflow * to ``0 `` and return ``-1 `` as usual.
145148
146149
147150.. c :function :: PY_LONG_LONG PyLong_AsLongLongAndOverflow (PyObject *pylong, int *overflow)
0 commit comments