src/multiresult.c
/**
 * This function raises exceptions from the MultiResult object, as required
 */
This function raises exceptions from the MultiResult object, as required
This function raises exceptions from the MultiResult object as required
int pycbc_multiresult_maybe_raise2(pycbc_MultiResult *self,
                                   pycbc_enhanced_err_info *err_info)
{
    PyObject *type = NULL, *value = NULL, *traceback = NULL;
    if (self->errop == NULL && self->exceptions == NULL) {
        return 0;
    }
    if (self->exceptions) {
        PyObject *tuple = PyList_GetItem(self->exceptions, 0);
        pycbc_assert(tuple);
        pycbc_assert(PyTuple_Size(tuple) == 3);
        type = PyTuple_GetItem(tuple, 0);
        value = PyTuple_GetItem(tuple, 1);
        traceback = PyTuple_GetItem(tuple, 2);
        PyErr_NormalizeException(&type, &value, &traceback);
        Py_XINCREF(type);
        Py_XINCREF(value);
        Py_XINCREF(traceback);
    } else {
        pycbc_Result *res = (pycbc_Result*)self->errop;
        PYCBC_EXC_WRAP_KEY_ERR_INFO(PYCBC_EXC_LCBERR,
                                    res->rc,
                                    "Operational Error",
                                    res->key,
                                    err_info ? err_info : self->err_info);
        PyErr_Fetch(&type, &value, &traceback);
        PyObject_SetAttrString(value, "result", (PyObject*)res);
    }
    if (PyObject_IsInstance(value, pycbc_helpers.default_exception)) {
        PyObject_SetAttrString(value, "all_results", (PyObject*)self);
        Py_XDECREF(self->exceptions);
    }
    Py_XDECREF(self->errop);
    self->exceptions = NULL;
    self->errop = NULL;
    PyErr_Restore(type, value, traceback);
    return 1;
}
int pycbc_multiresult_maybe_raise2 ( pycbc_MultiResult * self , pycbc_enhanced_err_info * err_info ) { PyObject * type = NULL , * value = NULL , * traceback = NULL ; if ( self -> errop == NULL && self -> exceptions == NULL ) { return 0 ; } if ( self -> exceptions ) { PyObject * tuple = PyList_GetItem ( self -> exceptions , 0 ) ; pycbc_assert ( tuple ) ; pycbc_assert ( PyTuple_Size ( tuple ) == 3 ) ; type = PyTuple_GetItem ( tuple , 0 ) ; value = PyTuple_GetItem ( tuple , 1 ) ; traceback = PyTuple_GetItem ( tuple , 2 ) ; PyErr_NormalizeException ( & type , & value , & traceback ) ; Py_XINCREF ( type ) ; Py_XINCREF ( value ) ; Py_XINCREF ( traceback ) ; } else { pycbc_Result * res = ( pycbc_Result * ) self -> errop ; PYCBC_EXC_WRAP_KEY_ERR_INFO ( PYCBC_EXC_LCBERR , res -> rc , " " , res -> key , err_info ? err_info : self -> err_info ) ; PyErr_Fetch ( & type , & value , & traceback ) ; PyObject_SetAttrString ( value , " " , ( PyObject * ) res ) ; } if ( PyObject_IsInstance ( value , pycbc_helpers . default_exception ) ) { PyObject_SetAttrString ( value , " " , ( PyObject * ) self ) ; Py_XDECREF ( self -> exceptions ) ; } Py_XDECREF ( self -> errop ) ; self -> exceptions = NULL ; self -> errop = NULL ; PyErr_Restore ( type , value , traceback ) ; return 1 ; }
This function raises exceptions from the MultiResult object, as required
This function raises exceptions from the MultiResult object as required
/** Craft an exception based on the operation */ /** Now we have an exception. Let's fetch it back */ /**
     * This is needed since the exception object will later contain
     * a reference to ourselves. If we don't free the original exception,
     * then we'll be stuck with a circular reference
     */