[Python-checkins] r86795 - in python/branches/py3k/Doc/extending: embedding.rst extending.rst

georg.brandl python-checkins at python.org
Fri Nov 26 12:55:49 CET 2010


Author: georg.brandl
Date: Fri Nov 26 12:55:48 2010
New Revision: 86795

Log:
Use PyLong_FromLong where appropriate.

Modified:
   python/branches/py3k/Doc/extending/embedding.rst
   python/branches/py3k/Doc/extending/extending.rst

Modified: python/branches/py3k/Doc/extending/embedding.rst
==============================================================================
--- python/branches/py3k/Doc/extending/embedding.rst	(original)
+++ python/branches/py3k/Doc/extending/embedding.rst	Fri Nov 26 12:55:48 2010
@@ -209,7 +209,7 @@
    {
        if(!PyArg_ParseTuple(args, ":numargs"))
            return NULL;
-       return Py_BuildValue("i", numargs);
+       return PyLong_FromLong(numargs);
    }
 
    static PyMethodDef EmbMethods[] = {

Modified: python/branches/py3k/Doc/extending/extending.rst
==============================================================================
--- python/branches/py3k/Doc/extending/extending.rst	(original)
+++ python/branches/py3k/Doc/extending/extending.rst	Fri Nov 26 12:55:48 2010
@@ -81,7 +81,7 @@
        if (!PyArg_ParseTuple(args, "s", &command))
            return NULL;
        sts = system(command);
-       return Py_BuildValue("i", sts);
+       return PyLong_FromLong(sts);
    }
 
 There is a straightforward translation from the argument list in Python (for
@@ -274,12 +274,9 @@
    sts = system(command);
 
 Our :func:`spam.system` function must return the value of :c:data:`sts` as a
-Python object.  This is done using the function :c:func:`Py_BuildValue`, which is
-something like the inverse of :c:func:`PyArg_ParseTuple`: it takes a format
-string and an arbitrary number of C values, and returns a new Python object.
-More info on :c:func:`Py_BuildValue` is given later. ::
+Python object.  This is done using the function :c:func:`PyLong_FromLong`. ::
 
-   return Py_BuildValue("i", sts);
+   return PyLong_FromLong(sts);
 
 In this case, it will return an integer object.  (Yes, even integers are objects
 on the heap in Python!)
@@ -1195,7 +1192,7 @@
        if (!PyArg_ParseTuple(args, "s", &command))
            return NULL;
        sts = PySpam_System(command);
-       return Py_BuildValue("i", sts);
+       return PyLong_FromLong(sts);
    }
 
 In the beginning of the module, right after the line ::


More information about the Python-checkins mailing list