public static void SetError(Exception e)
{
// Because delegates allow arbitrary nestings of Python calling
// managed calling Python calling... etc. it is possible that we
// might get a managed exception raised that is a wrapper for a
// Python exception. In that case we'd rather have the real thing.
PythonException pe = e as PythonException;
if (pe != null)
{
Runtime.PyErr_SetObject(pe.PyType, pe.PyValue);
return;
}
IntPtr op = CLRObject.GetInstHandle(e);
IntPtr etype = Runtime.PyObject_GetAttrString(op, "__class__");
Runtime.PyErr_SetObject(etype, op);
Runtime.XDecref(etype);
Runtime.XDecref(op);
}