//-----------------------------------------------------------------------------// Error.c// Error handling.//-----------------------------------------------------------------------------#include "Error.h"//-----------------------------------------------------------------------------// Error_Free()// Deallocate the environment, disconnecting from the database if necessary.//-----------------------------------------------------------------------------staticvoid Error_Free(dm_Error* self // error object){if (self->context != NULL){PyMem_Free(self->context);self->context = NULL;}Py_CLEAR(self->message);PyObject_Del(self);}//-----------------------------------------------------------------------------// Error_Str()// Return a string representation of the error variable.//-----------------------------------------------------------------------------staticPyObject*Error_Str(dm_Error* self // variable to return the string for){if (self->message) {Py_INCREF(self->message);return self->message;}return Py_BuildValue("s","");}//-----------------------------------------------------------------------------// declaration of members//-----------------------------------------------------------------------------static PyMemberDef g_ErrorMembers[] = {{ "code", T_INT, offsetof(dm_Error, code), READONLY },{ "offset", T_INT, offsetof(dm_Error, offset), READONLY },{ "message", T_OBJECT, offsetof(dm_Error, message), READONLY },{ "context", T_STRING, offsetof(dm_Error, context), READONLY },{ NULL }};//-----------------------------------------------------------------------------// declaration of Python type//-----------------------------------------------------------------------------PyTypeObject g_ErrorType = {PyVarObject_HEAD_INIT(NULL, 0)"dmPython.DmError", // tp_namesizeof(dm_Error), // tp_basicsize0, // tp_itemsize(destructor) Error_Free, // tp_dealloc0, // tp_print0, // tp_getattr0, // tp_setattr0, // tp_compare0, // tp_repr0, // tp_as_number0, // tp_as_sequence0, // tp_as_mapping0, // tp_hash0, // tp_call(reprfunc) Error_Str, // tp_str0, // tp_getattro0, // tp_setattro0, // tp_as_bufferPy_TPFLAGS_DEFAULT, // tp_flags0, // tp_doc0, // tp_traverse0, // tp_clear0, // tp_richcompare0, // tp_weaklistoffset0, // tp_iter0, // tp_iternext0, // tp_methodsg_ErrorMembers, // tp_members0 // tp_getset};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。