Index: extending.rst =================================================================== --- extending.rst (revision 82116) +++ extending.rst (working copy) @@ -231,7 +231,26 @@ We discuss the use of PyMODINIT_FUNC as a function return type later in this sample. +The :exc:`spam.error` exception can be raised in your extension module using +a call to :cfunc:`PyErr_SetString` as shown below:: + static PyObject * + spam_system(PyObject *self, PyObject *args) + { + const char *command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + if (sts < 0) + { + PyErr_SetString (SpamError, "System command failed"); + return NULL; + } + return Py_BuildValue("i", sts); + } + .. _backtoexample: Back to the Example