diff options
author | Georg Brandl <georg@python.org> | 2010-11-26 18:29:10 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-11-26 18:29:10 (GMT) |
commit | ae26cce9a3a4c659409583b3115f1c29050b1685 (patch) | |
tree | 015e91ce2ee89ebaab5d27600c8fd235396b78b8 /Doc/extending | |
parent | 67733311048573c734bbf98cebd474d308528514 (diff) | |
download | cpython-ae26cce9a3a4c659409583b3115f1c29050b1685.zip cpython-ae26cce9a3a4c659409583b3115f1c29050b1685.tar.gz cpython-ae26cce9a3a4c659409583b3115f1c29050b1685.tar.bz2 |
Recorded merge of revisions 86795,86798-86799,86801 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r86795 | georg.brandl | 2010-11-26 12:55:48 +0100 (Fr, 26 Nov 2010) | 1 line
Use PyLong_FromLong where appropriate.
........
r86798 | georg.brandl | 2010-11-26 13:05:48 +0100 (Fr, 26 Nov 2010) | 1 line
#10420: fix docs of bdb.effective().
........
r86799 | georg.brandl | 2010-11-26 13:08:19 +0100 (Fr, 26 Nov 2010) | 1 line
Remove parenthetical remark that is confusing now that the module is not named "__builtin__" anymore.
........
r86801 | georg.brandl | 2010-11-26 13:12:14 +0100 (Fr, 26 Nov 2010) | 1 line
Better example for os.system(): do not change the system time.
........
Diffstat (limited to 'Doc/extending')
-rw-r--r-- | Doc/extending/embedding.rst | 2 | ||||
-rw-r--r-- | Doc/extending/extending.rst | 13 |
2 files changed, 6 insertions, 9 deletions
diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst index 5c4fde8..2ea1253 100644 --- a/Doc/extending/embedding.rst +++ b/Doc/extending/embedding.rst @@ -209,7 +209,7 @@ Python extension. For example:: { if(!PyArg_ParseTuple(args, ":numargs")) return NULL; - return Py_BuildValue("i", numargs); + return PyLong_FromLong(numargs); } static PyMethodDef EmbMethods[] = { diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst index af983b3..83fa520 100644 --- a/Doc/extending/extending.rst +++ b/Doc/extending/extending.rst @@ -74,7 +74,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 @@ -266,13 +266,10 @@ the string we just got from :cfunc:`PyArg_ParseTuple`:: sts = system(command); -Our :func:`spam.system` function must return the value of :cdata:`sts` as a -Python object. This is done using the function :cfunc:`Py_BuildValue`, which is -something like the inverse of :cfunc:`PyArg_ParseTuple`: it takes a format -string and an arbitrary number of C values, and returns a new Python object. -More info on :cfunc:`Py_BuildValue` is given later. :: +Our :func:`spam.system` function must return the value of :c:data:`sts` as a +Python object. This is done using the function :cfunc:`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!) @@ -1193,7 +1190,7 @@ The function :cfunc:`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 :: |