summaryrefslogtreecommitdiffstats
path: root/Doc/extending
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-03 21:18:54 (GMT)
committerGeorg Brandl <georg@python.org>2009-01-03 21:18:54 (GMT)
commit48310cd3f2e02ced9ae836ccbcb67e9af3097d62 (patch)
tree04c86b387c11bfd4835a320e76bbb2ee24626e0d /Doc/extending
parent3d3558a4653fcfcbdcbb75bda5d61e93c48f4d51 (diff)
downloadcpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.zip
cpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.tar.gz
cpython-48310cd3f2e02ced9ae836ccbcb67e9af3097d62.tar.bz2
Remove trailing whitespace.
Diffstat (limited to 'Doc/extending')
-rw-r--r--Doc/extending/building.rst2
-rw-r--r--Doc/extending/extending.rst16
-rw-r--r--Doc/extending/newtypes.rst18
-rw-r--r--Doc/extending/windows.rst2
4 files changed, 19 insertions, 19 deletions
diff --git a/Doc/extending/building.rst b/Doc/extending/building.rst
index 1c7b53f..f4d95b2 100644
--- a/Doc/extending/building.rst
+++ b/Doc/extending/building.rst
@@ -39,7 +39,7 @@ Python file, which, in the most simple case, could look like this::
With this :file:`setup.py`, and a file :file:`demo.c`, running ::
- python setup.py build
+ python setup.py build
will compile :file:`demo.c`, and produce an extension module named ``demo`` in
the :file:`build` directory. Depending on the system, the module file will end
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);
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index e6b52c5..66af3bf 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -1180,7 +1180,7 @@ As with the :attr:`tp_methods` table, a sentinel entry with a :attr:`name` value
of *NULL* is required.
.. XXX Descriptors need to be explained in more detail somewhere, but not here.
-
+
Descriptor objects have two handler functions which correspond to the
\member{tp_getattro} and \member{tp_setattro} handlers. The
\method{__get__()} handler is a function which is passed the descriptor,
@@ -1233,15 +1233,15 @@ example that simply raises an exception; if this were really all you wanted, the
return -1;
}
-.. XXX tp_compare is dead; need to rewrite for tp_richcompare!
+.. XXX tp_compare is dead; need to rewrite for tp_richcompare!
Object Comparison
-----------------
-
+
::
-
+
cmpfunc tp_compare;
-
+
The :attr:`tp_compare` handler is called when comparisons are needed and the
object does not implement the specific rich comparison method which matches the
requested comparison. (It is always used if defined and the
@@ -1252,18 +1252,18 @@ example that simply raises an exception; if this were really all you wanted, the
allowed to return arbitrary negative or positive integers for less than and
greater than, respectively; as of Python 2.2, this is no longer allowed. In the
future, other return values may be assigned a different meaning.)
-
+
A :attr:`tp_compare` handler may raise an exception. In this case it should
return a negative value. The caller has to test for the exception using
:cfunc:`PyErr_Occurred`.
-
+
Here is a sample implementation::
-
+
static int
newdatatype_compare(newdatatypeobject * obj1, newdatatypeobject * obj2)
{
long result;
-
+
if (obj1->obj_UnderlyingDatatypePtr->size <
obj2->obj_UnderlyingDatatypePtr->size) {
result = -1;
diff --git a/Doc/extending/windows.rst b/Doc/extending/windows.rst
index 1675a0d..aac1d2d 100644
--- a/Doc/extending/windows.rst
+++ b/Doc/extending/windows.rst
@@ -102,7 +102,7 @@ described here are distributed with the Python sources in the
and it should call :cfunc:`Py_InitModule` with the string ``"spam"`` as its
first argument (use the minimal :file:`example.c` in this directory as a guide).
By convention, it lives in a file called :file:`spam.c` or :file:`spammodule.c`.
- The output file should be called :file:`spam.pyd` (in Release mode) or
+ The output file should be called :file:`spam.pyd` (in Release mode) or
:file:`spam_d.pyd` (in Debug mode). The extension :file:`.pyd` was chosen
to avoid confusion with a system library :file:`spam.dll` to which your module
could be a Python interface.