Skip to content

Commit 20941de

Browse files
authored
bpo-37999: Fix outdated __int__ and nb_int references in comments (GH-20449)
* Fix outdated __int__ and nb_int references in comments * Also update C-API documentation * Add back missing 'method' word * Remove .. deprecated notices
1 parent feb0846 commit 20941de

File tree

2 files changed

+33
-38
lines changed

2 files changed

+33
-38
lines changed

Doc/c-api/long.rst

+25-30
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
129129
single: OverflowError (built-in exception)
130130
131131
Return a C :c:type:`long` representation of *obj*. If *obj* is not an
132-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
133-
:meth:`__int__` method (if present) to convert it to a
134-
:c:type:`PyLongObject`.
132+
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
133+
(if present) to convert it to a :c:type:`PyLongObject`.
135134
136135
Raise :exc:`OverflowError` if the value of *obj* is out of range for a
137136
:c:type:`long`.
@@ -141,16 +140,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
141140
.. versionchanged:: 3.8
142141
Use :meth:`__index__` if available.
143142
144-
.. deprecated:: 3.8
145-
Using :meth:`__int__` is deprecated.
143+
.. versionchanged:: 3.10
144+
This function will no longer use :meth:`__int__`.
146145
147146
148147
.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
149148
150149
Return a C :c:type:`long` representation of *obj*. If *obj* is not an
151-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
152-
:meth:`__int__` method (if present) to convert it to a
153-
:c:type:`PyLongObject`.
150+
instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
151+
method (if present) to convert it to a :c:type:`PyLongObject`.
154152
155153
If the value of *obj* is greater than :const:`LONG_MAX` or less than
156154
:const:`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, and
@@ -162,8 +160,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
162160
.. versionchanged:: 3.8
163161
Use :meth:`__index__` if available.
164162
165-
.. deprecated:: 3.8
166-
Using :meth:`__int__` is deprecated.
163+
.. versionchanged:: 3.10
164+
This function will no longer use :meth:`__int__`.
167165
168166
169167
.. c:function:: long long PyLong_AsLongLong(PyObject *obj)
@@ -172,9 +170,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
172170
single: OverflowError (built-in exception)
173171
174172
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:`__index__` or
176-
:meth:`__int__` method (if present) to convert it to a
177-
:c:type:`PyLongObject`.
173+
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
174+
(if present) to convert it to a :c:type:`PyLongObject`.
178175
179176
Raise :exc:`OverflowError` if the value of *obj* is out of range for a
180177
:c:type:`long long`.
@@ -184,16 +181,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
184181
.. versionchanged:: 3.8
185182
Use :meth:`__index__` if available.
186183
187-
.. deprecated:: 3.8
188-
Using :meth:`__int__` is deprecated.
184+
.. versionchanged:: 3.10
185+
This function will no longer use :meth:`__int__`.
189186
190187
191188
.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
192189
193190
Return a C :c:type:`long long` representation of *obj*. If *obj* is not an
194-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
195-
:meth:`__int__` method (if present) to convert it to a
196-
:c:type:`PyLongObject`.
191+
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
192+
(if present) to convert it to a :c:type:`PyLongObject`.
197193
198194
If the value of *obj* is greater than :const:`LLONG_MAX` or less than
199195
:const:`LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively,
@@ -207,8 +203,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
207203
.. versionchanged:: 3.8
208204
Use :meth:`__index__` if available.
209205
210-
.. deprecated:: 3.8
211-
Using :meth:`__int__` is deprecated.
206+
.. versionchanged:: 3.10
207+
This function will no longer use :meth:`__int__`.
212208
213209
214210
.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
@@ -278,10 +274,9 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
278274
279275
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)
280276
281-
Return a C :c:type:`unsigned long` representation of *obj*. If *obj*
282-
is not an instance of :c:type:`PyLongObject`, first call its
283-
:meth:`__index__` or :meth:`__int__` method (if present) to convert
284-
it to a :c:type:`PyLongObject`.
277+
Return a C :c:type:`unsigned long` representation of *obj*. If *obj* is not
278+
an instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
279+
method (if present) to convert it to a :c:type:`PyLongObject`.
285280
286281
If the value of *obj* is out of range for an :c:type:`unsigned long`,
287282
return the reduction of that value modulo ``ULONG_MAX + 1``.
@@ -292,16 +287,16 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
292287
.. versionchanged:: 3.8
293288
Use :meth:`__index__` if available.
294289
295-
.. deprecated:: 3.8
296-
Using :meth:`__int__` is deprecated.
290+
.. versionchanged:: 3.10
291+
This function will no longer use :meth:`__int__`.
297292
298293
299294
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
300295
301296
Return a C :c:type:`unsigned long long` representation of *obj*. If *obj*
302297
is not an instance of :c:type:`PyLongObject`, first call its
303-
:meth:`__index__` or :meth:`__int__` method (if present) to convert
304-
it to a :c:type:`PyLongObject`.
298+
:meth:`__index__` method (if present) to convert it to a
299+
:c:type:`PyLongObject`.
305300
306301
If the value of *obj* is out of range for an :c:type:`unsigned long long`,
307302
return the reduction of that value modulo ``ULLONG_MAX + 1``.
@@ -312,8 +307,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
312307
.. versionchanged:: 3.8
313308
Use :meth:`__index__` if available.
314309
315-
.. deprecated:: 3.8
316-
Using :meth:`__int__` is deprecated.
310+
.. versionchanged:: 3.10
311+
This function will no longer use :meth:`__int__`.
317312
318313
319314
.. c:function:: double PyLong_AsDouble(PyObject *pylong)

Objects/longobject.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ PyLong_FromDouble(double dval)
363363
#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN)
364364
#define PY_ABS_SSIZE_T_MIN (0-(size_t)PY_SSIZE_T_MIN)
365365

366-
/* Get a C long int from an int object or any object that has an __int__
366+
/* Get a C long int from an int object or any object that has an __index__
367367
method.
368368
369369
On overflow, return -1 and set *overflow to 1 or -1 depending on the sign of
@@ -382,7 +382,7 @@ PyLong_AsLongAndOverflow(PyObject *vv, int *overflow)
382382
long res;
383383
Py_ssize_t i;
384384
int sign;
385-
int do_decref = 0; /* if nb_int was called */
385+
int do_decref = 0; /* if PyNumber_Index was called */
386386

387387
*overflow = 0;
388388
if (vv == NULL) {
@@ -449,7 +449,7 @@ PyLong_AsLongAndOverflow(PyObject *vv, int *overflow)
449449
return res;
450450
}
451451

452-
/* Get a C long int from an int object or any object that has an __int__
452+
/* Get a C long int from an int object or any object that has an __index__
453453
method. Return -1 and set an error if overflow occurs. */
454454

455455
long
@@ -466,7 +466,7 @@ PyLong_AsLong(PyObject *obj)
466466
return result;
467467
}
468468

469-
/* Get a C int from an int object or any object that has an __int__
469+
/* Get a C int from an int object or any object that has an __index__
470470
method. Return -1 and set an error if overflow occurs. */
471471

472472
int
@@ -1113,15 +1113,15 @@ PyLong_FromSsize_t(Py_ssize_t ival)
11131113
}
11141114

11151115
/* Get a C long long int from an int object or any object that has an
1116-
__int__ method. Return -1 and set an error if overflow occurs. */
1116+
__index__ method. Return -1 and set an error if overflow occurs. */
11171117

11181118
long long
11191119
PyLong_AsLongLong(PyObject *vv)
11201120
{
11211121
PyLongObject *v;
11221122
long long bytes;
11231123
int res;
1124-
int do_decref = 0; /* if nb_int was called */
1124+
int do_decref = 0; /* if PyNumber_Index was called */
11251125

11261126
if (vv == NULL) {
11271127
PyErr_BadInternalCall();
@@ -1257,7 +1257,7 @@ PyLong_AsUnsignedLongLongMask(PyObject *op)
12571257
}
12581258

12591259
/* Get a C long long int from an int object or any object that has an
1260-
__int__ method.
1260+
__index__ method.
12611261
12621262
On overflow, return -1 and set *overflow to 1 or -1 depending on the sign of
12631263
the result. Otherwise *overflow is 0.
@@ -1275,7 +1275,7 @@ PyLong_AsLongLongAndOverflow(PyObject *vv, int *overflow)
12751275
long long res;
12761276
Py_ssize_t i;
12771277
int sign;
1278-
int do_decref = 0; /* if nb_int was called */
1278+
int do_decref = 0; /* if PyNumber_Index was called */
12791279

12801280
*overflow = 0;
12811281
if (vv == NULL) {

0 commit comments

Comments
 (0)