A GOTO example (was question: numarray c extension...)

Josiah Carlson jcarlson at nospam.uci.edu
Fri Mar 12 18:26:12 CET 2004


It is arbitrarily trivial to convert it to use an error boolean.

  - Josiah



static PyObject * Py_Convolve1d(PyObject *obj, PyObject *args)
{
     PyObject   *okernel,...;
     PyArrayObject *kernel = NULL;
     bool error = 0;

     if (!PyArg_ParseTuple(args, "OO|O", &okernel, ...)) {
         PyErr_Format(_convolveError,
                     "Convolve1d: Invalid parameters.");
         error = 1;
     }
     kernel  = NA_IoArray(okernel, tFloat64, C_ARRAY);
     if (!kernel...) {
         PyErr_Format( _convolveError,
                  "Convolve1d: error converting array inputs.");
         error = 1;
     }

     ...more stuff...

     if (!error) {
         Py_XDECREF(kernel)
         return the result
     } else {
         Py_XDECREF(kernel)
         return NULL;
     }
}



More information about the Python-list mailing list