@@ -131,20 +131,28 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
131131 single: OverflowError (built-in exception)
132132
133133 Return a C :c:type:`long` representation of *obj*. If *obj* is not an
134- instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method
135- (if present) to convert it to a :c:type:`PyLongObject`.
134+ instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
135+ :meth:`__int__` method (if present) to convert it to a
136+ :c:type:`PyLongObject`.
136137
137138 Raise :exc:`OverflowError` if the value of *obj* is out of range for a
138139 :c:type:`long`.
139140
140141 Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
141142
143+ .. versionchanged:: 3.8
144+ Use :meth:`__index__` if available.
145+
146+ .. deprecated:: 3.8
147+ Using :meth:`__int__` is deprecated.
148+
142149
143150.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
144151
145152 Return a C :c:type: `long ` representation of *obj *. If *obj * is not an
146- instance of :c:type: `PyLongObject `, first call its :meth: `__int__ ` method
147- (if present) to convert it to a :c:type:`PyLongObject`.
153+ instance of :c:type: `PyLongObject `, first call its :meth: `__index__ ` or
154+ :meth: `__int__ ` method (if present) to convert it to a
155+ :c:type:`PyLongObject`.
148156
149157 If the value of *obj* is greater than :const :`LONG_MAX` or less than
150158 :const :`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, and
@@ -153,27 +161,41 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
153161
154162 Returns ``-1 `` on error. Use :c:func: `PyErr_Occurred ` to disambiguate.
155163
164+ .. versionchanged :: 3.8
165+ Use :meth: `__index__ ` if available.
166+
167+ .. deprecated :: 3.8
168+ Using :meth: `__int__ ` is deprecated.
169+
156170
157171.. c :function :: long long PyLong_AsLongLong (PyObject *obj)
158172
159173 .. index ::
160174 single: OverflowError (built-in exception)
161175
162176 Return a C :c:type:`long long` representation of *obj*. If *obj* is not an
163- instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method
164- (if present) to convert it to a :c:type:`PyLongObject`.
177+ instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
178+ :meth:`__int__` method (if present) to convert it to a
179+ :c:type:`PyLongObject`.
165180
166181 Raise :exc:`OverflowError` if the value of *obj* is out of range for a
167182 :c:type:`long`.
168183
169184 Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
170185
186+ .. versionchanged:: 3.8
187+ Use :meth:`__index__` if available.
188+
189+ .. deprecated:: 3.8
190+ Using :meth:`__int__` is deprecated.
191+
171192
172193.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
173194
174195 Return a C :c:type: `long long ` representation of *obj *. If *obj * is not an
175- instance of :c:type: `PyLongObject `, first call its :meth: `__int__ ` method
176- (if present) to convert it to a :c:type:`PyLongObject`.
196+ instance of :c:type: `PyLongObject `, first call its :meth: `__index__ ` or
197+ :meth: `__int__ ` method (if present) to convert it to a
198+ :c:type:`PyLongObject`.
177199
178200 If the value of *obj* is greater than :const :`PY_LLONG_MAX` or less than
179201 :const :`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively,
@@ -184,6 +206,12 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
184206
185207 .. versionadded :: 3.2
186208
209+ .. versionchanged :: 3.8
210+ Use :meth: `__index__ ` if available.
211+
212+ .. deprecated :: 3.8
213+ Using :meth: `__int__ ` is deprecated.
214+
187215
188216.. c :function :: Py_ssize_t PyLong_AsSsize_t (PyObject *pylong)
189217
@@ -253,26 +281,40 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
253281.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)
254282
255283 Return a C :c:type: `unsigned long ` representation of *obj *. If *obj *
256- is not an instance of :c:type: `PyLongObject `, first call its :meth: `__int__ `
257- method (if present) to convert it to a :c:type:`PyLongObject`.
284+ is not an instance of :c:type: `PyLongObject `, first call its
285+ :meth: `__index__ ` or :meth: `__int__ ` method (if present) to convert
286+ it to a :c:type:`PyLongObject`.
258287
259288 If the value of *obj* is out of range for an :c:type:`unsigned long`,
260289 return the reduction of that value modulo ``ULONG_MAX + 1``.
261290
262291 Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
263292
293+ .. versionchanged:: 3.8
294+ Use :meth:`__index__` if available.
295+
296+ .. deprecated:: 3.8
297+ Using :meth:`__int__` is deprecated.
298+
264299
265300.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
266301
267302 Return a C :c:type: `unsigned long long ` representation of *obj *. If *obj *
268- is not an instance of :c:type: `PyLongObject `, first call its :meth: `__int__ `
269- method (if present) to convert it to a :c:type:`PyLongObject`.
303+ is not an instance of :c:type: `PyLongObject `, first call its
304+ :meth: `__index__ ` or :meth: `__int__ ` method (if present) to convert
305+ it to a :c:type:`PyLongObject`.
270306
271307 If the value of *obj* is out of range for an :c:type:`unsigned long long`,
272308 return the reduction of that value modulo ``PY_ULLONG_MAX + 1``.
273309
274310 Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
275311
312+ .. versionchanged:: 3.8
313+ Use :meth:`__index__` if available.
314+
315+ .. deprecated:: 3.8
316+ Using :meth:`__int__` is deprecated.
317+
276318
277319.. c:function:: double PyLong_AsDouble(PyObject *pylong)
278320
0 commit comments