summaryrefslogtreecommitdiffstats
path: root/Doc/extending/extending.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-11-26 11:55:48 (GMT)
committerGeorg Brandl <georg@python.org>2010-11-26 11:55:48 (GMT)
commitc877a7c201d420cd3a72acbf04ceb79b591384a2 (patch)
treece6597fc28efac10ffe39f0a568d932a177c1e47 /Doc/extending/extending.rst
parent8449932320379dfafd3a745b553963408db897d9 (diff)
downloadcpython-c877a7c201d420cd3a72acbf04ceb79b591384a2.zip
cpython-c877a7c201d420cd3a72acbf04ceb79b591384a2.tar.gz
cpython-c877a7c201d420cd3a72acbf04ceb79b591384a2.tar.bz2
Use PyLong_FromLong where appropriate.
Diffstat (limited to 'Doc/extending/extending.rst')
-rw-r--r--Doc/extending/extending.rst11
1 files changed, 4 insertions, 7 deletions
diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst
index 1d40649..c4ced1a 100644
--- a/Doc/extending/extending.rst
+++ b/Doc/extending/extending.rst
@@ -81,7 +81,7 @@ shortly how it ends up being called)::
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 @@ the string we just got from :c:func:`PyArg_ParseTuple`::
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 @@ The function :c:func:`spam_system` is modified in a trivial way::
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 ::