[Python-3000-checkins] r59430 - python/branches/py3k/Doc/c-api/concrete.rst python/branches/py3k/Doc/c-api/intro.rst

georg.brandl python-3000-checkins at python.org
Sat Dec 8 19:58:51 CET 2007


Author: georg.brandl
Date: Sat Dec  8 19:58:51 2007
New Revision: 59430

Modified:
   python/branches/py3k/Doc/c-api/concrete.rst
   python/branches/py3k/Doc/c-api/intro.rst
Log:
Replace all remaining occurrences of PyInt_.


Modified: python/branches/py3k/Doc/c-api/concrete.rst
==============================================================================
--- python/branches/py3k/Doc/c-api/concrete.rst	(original)
+++ python/branches/py3k/Doc/c-api/concrete.rst	Sat Dec  8 19:58:51 2007
@@ -374,15 +374,6 @@
    :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 @@
       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) {

Modified: python/branches/py3k/Doc/c-api/intro.rst
==============================================================================
--- python/branches/py3k/Doc/c-api/intro.rst	(original)
+++ python/branches/py3k/Doc/c-api/intro.rst	Sat Dec  8 19:58:51 2007
@@ -208,11 +208,11 @@
    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 @@
        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 @@
            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 @@
            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 @@
 
            /* 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;
 


More information about the Python-3000-checkins mailing list