Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d019fe2

Browse files
committed
Replace all remaining occurrences of PyInt_.
1 parent 0aa93cd commit d019fe2

2 files changed

Lines changed: 15 additions & 21 deletions

File tree

Doc/c-api/concrete.rst

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,6 @@ All integers are implemented as "long" integer objects of arbitrary size.
374374
:cfunc:`PyLong_FromVoidPtr`.
375375

376376

377-
.. XXX name?
378-
.. cfunction:: long PyInt_GetMax()
379-
380-
.. index:: single: LONG_MAX
381-
382-
Return the system's idea of the largest integer it can handle
383-
(:const:`LONG_MAX`, as defined in the system header files).
384-
385-
386377
.. _floatobjects:
387378

388379
Floating Point Objects
@@ -2275,8 +2266,11 @@ Dictionary Objects
22752266
Py_ssize_t pos = 0;
22762267

22772268
while (PyDict_Next(self->dict, &pos, &key, &value)) {
2278-
int i = PyInt_AS_LONG(value) + 1;
2279-
PyObject *o = PyInt_FromLong(i);
2269+
long i = PyLong_AsLong(value);
2270+
if (i == -1 && PyErr_Occurred()) {
2271+
return -1;
2272+
}
2273+
PyObject *o = PyLong_FromLong(i + 1);
22802274
if (o == NULL)
22812275
return -1;
22822276
if (PyDict_SetItem(self->dict, key, o) < 0) {

Doc/c-api/intro.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ error handling for the moment; a better way to code this is shown below)::
208208
PyObject *t;
209209

210210
t = PyTuple_New(3);
211-
PyTuple_SetItem(t, 0, PyInt_FromLong(1L));
212-
PyTuple_SetItem(t, 1, PyInt_FromLong(2L));
211+
PyTuple_SetItem(t, 0, PyLong_FromLong(1L));
212+
PyTuple_SetItem(t, 1, PyLong_FromLong(2L));
213213
PyTuple_SetItem(t, 2, PyString_FromString("three"));
214214

215-
Here, :cfunc:`PyInt_FromLong` returns a new reference which is immediately
215+
Here, :cfunc:`PyLong_FromLong` returns a new reference which is immediately
216216
stolen by :cfunc:`PyTuple_SetItem`. When you want to keep using an object
217217
although the reference to it will be stolen, use :cfunc:`Py_INCREF` to grab
218218
another reference before calling the reference-stealing function.
@@ -252,7 +252,7 @@ sets all items of a list (actually, any mutable sequence) to a given item::
252252
if (n < 0)
253253
return -1;
254254
for (i = 0; i < n; i++) {
255-
PyObject *index = PyInt_FromLong(i);
255+
PyObject *index = PyLong_FromLong(i);
256256
if (!index)
257257
return -1;
258258
if (PyObject_SetItem(target, index, item) < 0)
@@ -301,8 +301,8 @@ using :cfunc:`PySequence_GetItem`. ::
301301
return -1; /* Not a list */
302302
for (i = 0; i < n; i++) {
303303
item = PyList_GetItem(list, i); /* Can't fail */
304-
if (!PyInt_Check(item)) continue; /* Skip non-integers */
305-
total += PyInt_AsLong(item);
304+
if (!PyLong_Check(item)) continue; /* Skip non-integers */
305+
total += PyLong_AsLong(item);
306306
}
307307
return total;
308308
}
@@ -324,8 +324,8 @@ using :cfunc:`PySequence_GetItem`. ::
324324
item = PySequence_GetItem(sequence, i);
325325
if (item == NULL)
326326
return -1; /* Not a sequence, or other failure */
327-
if (PyInt_Check(item))
328-
total += PyInt_AsLong(item);
327+
if (PyLong_Check(item))
328+
total += PyLong_AsLong(item);
329329
Py_DECREF(item); /* Discard reference ownership */
330330
}
331331
return total;
@@ -449,11 +449,11 @@ Here is the corresponding C code, in all its glory::
449449

450450
/* Clear the error and use zero: */
451451
PyErr_Clear();
452-
item = PyInt_FromLong(0L);
452+
item = PyLong_FromLong(0L);
453453
if (item == NULL)
454454
goto error;
455455
}
456-
const_one = PyInt_FromLong(1L);
456+
const_one = PyLong_FromLong(1L);
457457
if (const_one == NULL)
458458
goto error;
459459

0 commit comments

Comments
 (0)