summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-12-08 18:58:51 (GMT)
committerGeorg Brandl <georg@python.org>2007-12-08 18:58:51 (GMT)
commitd019fe295ee464bd81572d9f58d89e23b39cecfe (patch)
tree4c3109c7f3c7bb1b5e4f34ce7c38a5c47b0eb102 /Doc/c-api
parent0aa93cda79936564e960da85a1ad806c55e580f9 (diff)
downloadcpython-d019fe295ee464bd81572d9f58d89e23b39cecfe.zip
cpython-d019fe295ee464bd81572d9f58d89e23b39cecfe.tar.gz
cpython-d019fe295ee464bd81572d9f58d89e23b39cecfe.tar.bz2
Replace all remaining occurrences of PyInt_.
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/concrete.rst16
-rw-r--r--Doc/c-api/intro.rst20
2 files changed, 15 insertions, 21 deletions
diff --git a/Doc/c-api/concrete.rst b/Doc/c-api/concrete.rst
index f90ab4f..5ff8969 100644
--- a/Doc/c-api/concrete.rst
+++ b/Doc/c-api/concrete.rst
@@ -374,15 +374,6 @@ All integers are implemented as "long" integer objects of arbitrary size.
:cfunc:`PyLong_FromVoidPtr`.
-.. XXX name?
-.. cfunction:: long PyInt_GetMax()
-
- .. index:: single: LONG_MAX
-
- Return the system's idea of the largest integer it can handle
- (:const:`LONG_MAX`, as defined in the system header files).
-
-
.. _floatobjects:
Floating Point Objects
@@ -2275,8 +2266,11 @@ Dictionary Objects
Py_ssize_t pos = 0;
while (PyDict_Next(self->dict, &pos, &key, &value)) {
- int i = PyInt_AS_LONG(value) + 1;
- PyObject *o = PyInt_FromLong(i);
+ long i = PyLong_AsLong(value);
+ if (i == -1 && PyErr_Occurred()) {
+ return -1;
+ }
+ PyObject *o = PyLong_FromLong(i + 1);
if (o == NULL)
return -1;
if (PyDict_SetItem(self->dict, key, o) < 0) {
diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst
index 0717241..54412cd 100644
--- a/Doc/c-api/intro.rst
+++ b/Doc/c-api/intro.rst
@@ -208,11 +208,11 @@ error handling for the moment; a better way to code this is shown below)::
PyObject *t;
t = PyTuple_New(3);
- PyTuple_SetItem(t, 0, PyInt_FromLong(1L));
- PyTuple_SetItem(t, 1, PyInt_FromLong(2L));
+ PyTuple_SetItem(t, 0, PyLong_FromLong(1L));
+ PyTuple_SetItem(t, 1, PyLong_FromLong(2L));
PyTuple_SetItem(t, 2, PyString_FromString("three"));
-Here, :cfunc:`PyInt_FromLong` returns a new reference which is immediately
+Here, :cfunc:`PyLong_FromLong` returns a new reference which is immediately
stolen by :cfunc:`PyTuple_SetItem`. When you want to keep using an object
although the reference to it will be stolen, use :cfunc:`Py_INCREF` to grab
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::
if (n < 0)
return -1;
for (i = 0; i < n; i++) {
- PyObject *index = PyInt_FromLong(i);
+ PyObject *index = PyLong_FromLong(i);
if (!index)
return -1;
if (PyObject_SetItem(target, index, item) < 0)
@@ -301,8 +301,8 @@ using :cfunc:`PySequence_GetItem`. ::
return -1; /* Not a list */
for (i = 0; i < n; i++) {
item = PyList_GetItem(list, i); /* Can't fail */
- if (!PyInt_Check(item)) continue; /* Skip non-integers */
- total += PyInt_AsLong(item);
+ if (!PyLong_Check(item)) continue; /* Skip non-integers */
+ total += PyLong_AsLong(item);
}
return total;
}
@@ -324,8 +324,8 @@ using :cfunc:`PySequence_GetItem`. ::
item = PySequence_GetItem(sequence, i);
if (item == NULL)
return -1; /* Not a sequence, or other failure */
- if (PyInt_Check(item))
- total += PyInt_AsLong(item);
+ if (PyLong_Check(item))
+ total += PyLong_AsLong(item);
Py_DECREF(item); /* Discard reference ownership */
}
return total;
@@ -449,11 +449,11 @@ Here is the corresponding C code, in all its glory::
/* Clear the error and use zero: */
PyErr_Clear();
- item = PyInt_FromLong(0L);
+ item = PyLong_FromLong(0L);
if (item == NULL)
goto error;
}
- const_one = PyInt_FromLong(1L);
+ const_one = PyLong_FromLong(1L);
if (const_one == NULL)
goto error;