@@ -108,26 +108,29 @@ All integers are implemented as "long" integer objects of arbitrary size.
108108
109109
110110.. XXX alias PyLong_AS_LONG (for now)
111- .. c :function :: long PyLong_AsLong (PyObject *pylong )
111+ .. c :function :: long PyLong_AsLong (PyObject *obj )
112112
113113 .. index ::
114114 single: LONG_MAX
115115 single: OverflowError (built-in exception)
116116
117- Return a C :c:type:`long` representation of the contents of *pylong*. If
118- *pylong* is greater than :const :`LONG_MAX`, raise an :exc:`OverflowError`,
119- and return -1. Convert non-long objects automatically to long first,
120- and return -1 if that raises exceptions.
117+ Return a C :c:type:`long` representation of *obj*. If *obj* is not an
118+ instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method
119+ (if present) to convert it to a :c:type:`PyLongObject`.
121120
122- .. c:function:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow)
121+ Raise :exc:`OverflowError` if the value of *obj* is out of range for a
122+ :c:type:`long`.
123123
124- Return a C :c:type: `long ` representation of the contents of
125- *pylong *. If *pylong * is greater than :const: `LONG_MAX ` or less
126- than :const: `LONG_MIN `, set *\* overflow * to ``1 `` or ``-1 ``,
127- respectively, and return ``-1 ``; otherwise, set *\* overflow * to
128- ``0 ``. If any other exception occurs (for example a TypeError or
129- MemoryError), then ``-1`` will be returned and *\*overflow* will
130- be ``0``.
124+ .. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
125+
126+ Return a C :c:type: `long ` representation of *obj *. If *obj * is not an
127+ instance of :c:type: `PyLongObject `, first call its :meth: `__int__ ` method
128+ (if present) to convert it to a :c:type:`PyLongObject`.
129+
130+ If the value of *obj* is greater than :const :`LONG_MAX` or less than
131+ :const :`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, and
132+ return ``-1``; otherwise, set *\*overflow* to ``0 ``. If any other exception
133+ occurs set *\* overflow * to ``0 `` and return ``-1 `` as usual.
131134
132135
133136.. c :function :: PY_LONG_LONG PyLong_AsLongLongAndOverflow (PyObject *pylong, int *overflow)
0 commit comments