diff options
author | Georg Brandl <georg@python.org> | 2009-01-03 21:18:54 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-01-03 21:18:54 (GMT) |
commit | 48310cd3f2e02ced9ae836ccbcb67e9af3097d62 (patch) | |
tree | 04c86b387c11bfd4835a320e76bbb2ee24626e0d /Doc/extending/extending.rst | |
parent | 3d3558a4653fcfcbdcbb75bda5d61e93c48f4d51 (diff) | |
download | cpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.zip cpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.tar.gz cpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.tar.bz2 |
Remove trailing whitespace.
Diffstat (limited to 'Doc/extending/extending.rst')
-rw-r--r-- | Doc/extending/extending.rst | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst index 17a8110..ed86073 100644 --- a/Doc/extending/extending.rst +++ b/Doc/extending/extending.rst @@ -334,7 +334,7 @@ When the Python program imports module :mod:`spam` for the first time, :cfunc:`PyInit_spam` is called. (See below for comments about embedding Python.) It calls :cfunc:`PyModule_Create`, which returns a module object, and inserts built-in function objects into the newly created module based upon the -table (an array of :ctype:`PyMethodDef` structures) found in the module definition. +table (an array of :ctype:`PyMethodDef` structures) found in the module definition. :cfunc:`PyModule_Create` returns a pointer to the module object that it creates. It may abort with a fatal error for certain errors, or return *NULL* if the module could not be initialized @@ -482,7 +482,7 @@ Later, when it is time to call the function, you call the C function :cfunc:`PyEval_CallObject`. This function has two arguments, both pointers to arbitrary Python objects: the Python function, and the argument list. The argument list must always be a tuple object, whose length is the number of -arguments. To call the Python function with no arguments, pass in NULL, or +arguments. To call the Python function with no arguments, pass in NULL, or an empty tuple; to call it with one argument, pass a singleton tuple. :cfunc:`Py_BuildValue` returns a tuple when its format string consists of zero or more format codes between parentheses. For example:: @@ -521,7 +521,7 @@ If this is not possible or desirable, the exception should be cleared by calling if (result == NULL) return NULL; /* Pass error back */ ...use result... - Py_DECREF(result); + Py_DECREF(result); Depending on the desired interface to the Python callback function, you may also have to provide an argument list to :cfunc:`PyEval_CallObject`. In some cases @@ -546,7 +546,7 @@ Note the placement of ``Py_DECREF(arglist)`` immediately after the call, before the error check! Also note that strictly speaking this code is not complete: :cfunc:`Py_BuildValue` may run out of memory, and this should be checked. -You may also call a function with keyword arguments by using +You may also call a function with keyword arguments by using :cfunc:`PyEval_CallObjectWithKeywords`. As in the above example, we use :cfunc:`Py_BuildValue` to construct the dictionary. :: @@ -687,7 +687,7 @@ Philbrick (philbrick@hks.com):: static PyObject * keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds) - { + { int voltage; char *state = "a stiff"; char *action = "voom"; @@ -695,11 +695,11 @@ Philbrick (philbrick@hks.com):: static char *kwlist[] = {"voltage", "state", "action", "type", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sss", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sss", kwlist, &voltage, &state, &action, &type)) - return NULL; + return NULL; - printf("-- This parrot wouldn't %s if you put %i Volts through it.\n", + printf("-- This parrot wouldn't %s if you put %i Volts through it.\n", action, voltage); printf("-- Lovely plumage, the %s -- It's %s!\n", type, state); |