ext/redrat_ext/redrat_ext.c
/*
 * redrat_exception_convert - Convert Python exceptions to Ruby exceptions
 *
 * This procedure presumes that the Python GIL is already held.
 *
 * The convention in the Python C API is to allow NULL-valued PyObject* values
 * flow through the system while an out-of-band error state is left intact.
 * Before returning control to MRI, determine if it is necessary to raise a
 * Ruby exception or not.
 */
Convert Python exceptions to Ruby exceptions
This procedure presumes that the Python GIL is already held.

The convention in the Python C API is to allow NULL-valued PyObject* values
flow through the system while an out-of-band error state is left intact.
Before returning control to MRI, determine if it is necessary to raise a
Ruby exception or not.
Convert Python exceptions to Ruby exceptions This procedure presumes that the Python GIL is already held . The convention in the Python C API is to allow NULL - valued PyObject * values flow through the system while an out - of - band error state is left intact . Before returning control to MRI determine if it is necessary to raise a Ruby exception or not .
static VALUE
redrat_exception_convert()
{
    PyObject *pType;
    PyObject *pValue;
    PyObject *pTraceback;
    PyErr_Fetch(&pType, &pValue, &pTraceback);
    if (pType != NULL)
    {
        VALUE rException;
        VALUE rpType;
        VALUE rpValue = Qnil;
        VALUE rpTraceback = Qnil;
        rpType = redrat_ruby_handoff(pType);
        if (pValue != NULL)
            rpValue = redrat_ruby_handoff(pValue);
        if (pTraceback != NULL)
            rpTraceback = redrat_ruby_handoff(pTraceback);
        rException = rb_exc_new2(rb_eRedRatException, "RedRat exception");
        rb_iv_set(rException, "@python_type", rpType);
        rb_iv_set(rException, "@python_value", rpValue);
        rb_iv_set(rException, "@python_traceback", rpTraceback);
        Py_DECREF(pType);
        Py_XDECREF(pValue);
        Py_XDECREF(pTraceback);
        PyErr_Clear();
        return rException;
    }
    else
    {
        Assert(pValue == NULL);
        rb_bug("redrat_ext: expected Python error state, "
               "but no error state was found");
    }
}
static VALUE redrat_exception_convert ( ) { PyObject * pType ; PyObject * pValue ; PyObject * pTraceback ; PyErr_Fetch ( & pType , & pValue , & pTraceback ) ; if ( pType != NULL ) { VALUE rException ; VALUE rpType ; VALUE rpValue = Qnil ; VALUE rpTraceback = Qnil ; rpType = redrat_ruby_handoff ( pType ) ; if ( pValue != NULL ) rpValue = redrat_ruby_handoff ( pValue ) ; if ( pTraceback != NULL ) rpTraceback = redrat_ruby_handoff ( pTraceback ) ; rException = rb_exc_new2 ( rb_eRedRatException , " " ) ; rb_iv_set ( rException , " " , rpType ) ; rb_iv_set ( rException , " " , rpValue ) ; rb_iv_set ( rException , " " , rpTraceback ) ; Py_DECREF ( pType ) ; Py_XDECREF ( pValue ) ; Py_XDECREF ( pTraceback ) ; PyErr_Clear ( ) ; return rException ; } else { Assert ( pValue == NULL ) ; rb_bug ( " " " " ) ; } }
redrat_exception_convert - Convert Python exceptions to Ruby exceptions
 This procedure presumes that the Python GIL is already held.
redrat_exception_convert - Convert Python exceptions to Ruby exceptions This procedure presumes that the Python GIL is already held .
/* The trinity of Python exception information, see PyErr_Fetch */