Cleanup: style, use braces for the Python API

This commit is contained in:
2019-03-30 06:12:48 +11:00
parent 18d06e8d21
commit 25ec4b437f
39 changed files with 1689 additions and 800 deletions

View File

@@ -126,9 +126,15 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
return NULL;
}
if (absolute) flag |= BKE_BPATH_TRAVERSE_ABS;
if (!packed) flag |= BKE_BPATH_TRAVERSE_SKIP_PACKED;
if (local) flag |= BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
if (absolute) {
flag |= BKE_BPATH_TRAVERSE_ABS;
}
if (!packed) {
flag |= BKE_BPATH_TRAVERSE_SKIP_PACKED;
}
if (local) {
flag |= BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
}
list = PyList_New(0);
@@ -157,10 +163,10 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
}
/* stupid string compare */
if (STREQ(type, "DATAFILES")) folder_id = BLENDER_USER_DATAFILES;
else if (STREQ(type, "CONFIG")) folder_id = BLENDER_USER_CONFIG;
else if (STREQ(type, "SCRIPTS")) folder_id = BLENDER_USER_SCRIPTS;
else if (STREQ(type, "AUTOSAVE")) folder_id = BLENDER_USER_AUTOSAVE;
if (STREQ(type, "DATAFILES")) { folder_id = BLENDER_USER_DATAFILES; }
else if (STREQ(type, "CONFIG")) { folder_id = BLENDER_USER_CONFIG; }
else if (STREQ(type, "SCRIPTS")) { folder_id = BLENDER_USER_SCRIPTS; }
else if (STREQ(type, "AUTOSAVE")) { folder_id = BLENDER_USER_AUTOSAVE; }
else {
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
return NULL;
@@ -203,9 +209,9 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
}
/* stupid string compare */
if (STREQ(type, "USER")) folder_id = BLENDER_RESOURCE_PATH_USER;
else if (STREQ(type, "LOCAL")) folder_id = BLENDER_RESOURCE_PATH_LOCAL;
else if (STREQ(type, "SYSTEM")) folder_id = BLENDER_RESOURCE_PATH_SYSTEM;
if (STREQ(type, "USER")) { folder_id = BLENDER_RESOURCE_PATH_USER; }
else if (STREQ(type, "LOCAL")) { folder_id = BLENDER_RESOURCE_PATH_LOCAL; }
else if (STREQ(type, "SYSTEM")) { folder_id = BLENDER_RESOURCE_PATH_SYSTEM; }
else {
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
return NULL;

View File

@@ -253,8 +253,12 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *clos
return -1;
}
if (param) G.debug |= flag;
else G.debug &= ~flag;
if (param) {
G.debug |= flag;
}
else {
G.debug &= ~flag;
}
return 0;
}
@@ -278,8 +282,12 @@ static int bpy_app_global_flag_set(PyObject *UNUSED(self), PyObject *value, void
return -1;
}
if (param) G.f |= flag;
else G.f &= ~flag;
if (param) {
G.f |= flag;
}
else {
G.f &= ~flag;
}
return 0;
}

View File

@@ -90,8 +90,9 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type), PyO
{
PyObject *value;
if (!PyArg_ParseTuple(args, "O:bpy.app.handlers.persistent", &value))
if (!PyArg_ParseTuple(args, "O:bpy.app.handlers.persistent", &value)) {
return NULL;
}
if (PyFunction_Check(value)) {
PyObject **dict_ptr = _PyObject_GetDictPtr(value);

View File

@@ -89,8 +89,9 @@ static bool _ghashutil_keycmp(const void *a, const void *b)
const GHashKey *B = b;
/* Note: comparing msgid first, most of the time it will be enough! */
if (BLI_ghashutil_strcmp(A->msgid, B->msgid) == false)
if (BLI_ghashutil_strcmp(A->msgid, B->msgid) == false) {
return BLI_ghashutil_strcmp(A->msgctxt, B->msgctxt);
}
return true; /* true means they are not equal! */
}
@@ -249,8 +250,9 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms
const char *tmp;
/* Just in case, should never happen! */
if (!_translations)
if (!_translations) {
return msgid;
}
tmp = BLT_lang_get();
if (!STREQ(tmp, locale) || !_translations_cache) {
@@ -458,8 +460,9 @@ static PyObject *app_translations_locales_get(PyObject *UNUSED(self), void *UNUS
if (items) {
/* This is not elegant, but simple! */
for (it = items; it->identifier; it++) {
if (it->value)
if (it->value) {
num_locales++;
}
}
}
@@ -467,8 +470,9 @@ static PyObject *app_translations_locales_get(PyObject *UNUSED(self), void *UNUS
if (items) {
for (it = items; it->identifier; it++) {
if (it->value)
if (it->value) {
PyTuple_SET_ITEM(ret, pos++, PyUnicode_FromString(it->description));
}
}
}
@@ -801,8 +805,9 @@ PyObject *BPY_app_translations_struct(void)
PyStructSequence_InitType(&BlenderAppTranslationsContextsType, &app_translations_contexts_desc);
}
if (PyType_Ready(&BlenderAppTranslationsType) < 0)
if (PyType_Ready(&BlenderAppTranslationsType) < 0) {
return NULL;
}
ret = PyObject_CallObject((PyObject *)&BlenderAppTranslationsType, NULL);

View File

@@ -48,8 +48,9 @@ char *BPy_enum_as_string(const EnumPropertyItem *item)
char *cstring;
for (e = item; item->identifier; item++) {
if (item->identifier[0])
if (item->identifier[0]) {
BLI_dynstr_appendf(dynstr, (e == item) ? "'%s'" : ", '%s'", item->identifier);
}
}
cstring = BLI_dynstr_get_cstring(dynstr);
@@ -93,8 +94,9 @@ bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const boo
{
PyObject *pystring;
if (!PyErr_Occurred())
if (!PyErr_Occurred()) {
return 1;
}
/* less hassle if we allow NULL */
if (reports == NULL) {

View File

@@ -69,13 +69,17 @@ int bpy_pydriver_create_dict(void)
PyObject *d, *mod;
/* validate namespace for driver evaluation */
if (bpy_pydriver_Dict) return -1;
if (bpy_pydriver_Dict) {
return -1;
}
d = PyDict_New();
if (d == NULL)
if (d == NULL) {
return -1;
else
}
else {
bpy_pydriver_Dict = d;
}
/* import some modules: builtins, bpy, math, (Blender.noise)*/
PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
@@ -205,8 +209,9 @@ void BPY_driver_reset(void)
PyGILState_STATE gilstate;
bool use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
PyDict_Clear(bpy_pydriver_Dict);
@@ -227,8 +232,9 @@ void BPY_driver_reset(void)
/* freed when clearing driver dict */
g_pydriver_state_prev.self = NULL;
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
return;
}
@@ -399,8 +405,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
/* get the py expression to be evaluated */
expr = driver_orig->expression;
if (expr[0] == '\0')
if (expr[0] == '\0') {
return 0.0f;
}
#ifndef USE_BYTECODE_WHITELIST
if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) {
@@ -418,8 +425,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
/* needed since drivers are updated directly after undo where 'main' is
* re-allocated [#28807] */
@@ -429,8 +437,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
if (!bpy_pydriver_Dict) {
if (bpy_pydriver_create_dict() != 0) {
fprintf(stderr, "PyDriver error: couldn't create Python dictionary\n");
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
return 0.0f;
}
}
@@ -445,8 +454,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
bpy_pydriver_namespace_clear_self();
}
if (driver_orig->expr_comp == NULL)
if (driver_orig->expr_comp == NULL) {
driver_orig->flag |= DRIVER_FLAG_RECOMPILE;
}
/* compile the expression first if it hasn't been compiled or needs to be rebuilt */
if (driver_orig->flag & DRIVER_FLAG_RECOMPILE) {
@@ -571,8 +581,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict, driver_vars);
#else
/* evaluate the compiled expression */
if (expr_code)
if (expr_code) {
retval = PyEval_EvalCode((void *)expr_code, bpy_pydriver_Dict, driver_vars);
}
#endif
/* decref the driver vars first... */
@@ -593,8 +604,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
Py_DECREF(retval);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (isfinite(result)) {
return (float)result;

View File

@@ -98,8 +98,9 @@ void BPY_context_update(bContext *C)
/* don't do this from a non-main (e.g. render) thread, it can cause a race
* condition on C->data.recursion. ideal solution would be to disable
* context entirely from non-main threads, but that's more complicated */
if (!BLI_thread_is_main())
if (!BLI_thread_is_main()) {
return;
}
BPy_SetContext(C);
bpy_import_main_set(CTX_data_main(C));
@@ -110,8 +111,9 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
{
py_call_level++;
if (gilstate)
if (gilstate) {
*gilstate = PyGILState_Ensure();
}
if (py_call_level == 1) {
BPY_context_update(C);
@@ -135,8 +137,9 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
{
py_call_level--;
if (gilstate)
if (gilstate) {
PyGILState_Release(*gilstate);
}
if (py_call_level < 0) {
fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n");
@@ -163,14 +166,16 @@ void BPY_text_free_code(Text *text)
PyGILState_STATE gilstate;
bool use_gil = !PyC_IsInterpreterActive();
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
Py_DECREF((PyObject *)text->compiled);
text->compiled = NULL;
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
}
}
@@ -184,8 +189,9 @@ void BPY_modules_update(bContext *C)
/* refreshes the main struct */
BPY_update_rna_module();
if (bpy_context_module)
if (bpy_context_module) {
bpy_context_module->ptr.data = (void *)C;
}
}
void BPY_context_set(bContext *C)
@@ -371,11 +377,13 @@ void BPY_python_end(void)
printf("*bpy stats* - ");
printf("tot exec: %d, ", bpy_timer_count);
printf("tot run: %.4fsec, ", bpy_timer_run_tot);
if (bpy_timer_count > 0)
if (bpy_timer_count > 0) {
printf("average run: %.6fsec, ", (bpy_timer_run_tot / bpy_timer_count));
}
if (bpy_timer > 0.0)
if (bpy_timer > 0.0) {
printf("tot usage %.4f%%", (bpy_timer_run_tot / bpy_timer) * 100.0);
}
printf("\n");
@@ -750,8 +758,9 @@ void BPY_modules_load_user(bContext *C)
Text *text;
/* can happen on file load */
if (bmain == NULL)
if (bmain == NULL) {
return;
}
/* update pointers since this can run from a nested script
* on file load */
@@ -802,8 +811,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
PointerRNA *ptr = NULL;
bool done = false;
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
pyctx = (PyObject *)CTX_py_dict_get(C);
item = PyDict_GetItemString(pyctx, member);
@@ -870,8 +880,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
CLOG_INFO(BPY_LOG_CONTEXT, 2, "'%s' found", member);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
return done;
}
@@ -971,8 +982,9 @@ PyInit_bpy(void)
dealloc_obj_Type.tp_dealloc = dealloc_obj_dealloc;
dealloc_obj_Type.tp_flags = Py_TPFLAGS_DEFAULT;
if (PyType_Ready(&dealloc_obj_Type) < 0)
if (PyType_Ready(&dealloc_obj_Type) < 0) {
return NULL;
}
dob = (dealloc_obj *) dealloc_obj_Type.tp_alloc(&dealloc_obj_Type, 0);
dob->mod = bpy_proxy; /* borrow */

View File

@@ -476,8 +476,9 @@ int BPY_library_load_module(PyObject *mod_par)
/* some compilers don't like accessing this directly, delay assignment */
bpy_lib_Type.tp_getattro = PyObject_GenericGetAttr;
if (PyType_Ready(&bpy_lib_Type) < 0)
if (PyType_Ready(&bpy_lib_Type) < 0) {
return -1;
}
return 0;
}

View File

@@ -93,8 +93,9 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
if (!PyArg_ParseTuple(args, "s|Os:_bpy.ops.poll", &opname, &context_dict, &context_str))
if (!PyArg_ParseTuple(args, "s|Os:_bpy.ops.poll", &opname, &context_dict, &context_str)) {
return NULL;
}
ot = WM_operatortype_find(opname, true);
@@ -362,8 +363,9 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
error_val = pyrna_pydict_to_props(&ptr, kw, false, "Converting py args to operator properties: ");
}
if (error_val == 0)
if (error_val == 0) {
buf = WM_operator_pystring_ex(C, NULL, all_args, macro_args, ot, &ptr);
}
WM_operator_properties_free(&ptr);

View File

@@ -162,8 +162,9 @@ PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args)
const char *opname;
const char *macroname;
if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", &macro, &opname))
if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", &macro, &opname)) {
return NULL;
}
if (WM_operatortype_find(opname, true) == NULL) {
PyErr_Format(PyExc_ValueError,

View File

@@ -201,10 +201,12 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
PyTuple_SET_ITEM(ret, 0, func);
Py_INCREF(func);
if (kw == NULL)
if (kw == NULL) {
kw = PyDict_New();
else
}
else {
Py_INCREF(kw);
}
PyTuple_SET_ITEM(ret, 1, kw);
@@ -282,8 +284,9 @@ static bool bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -313,8 +316,9 @@ static bool bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -342,8 +346,9 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -369,8 +374,9 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -395,8 +401,9 @@ static bool bpy_prop_poll_cb(struct PointerRNA *self, PointerRNA candidate, stru
py_candidate = pyrna_struct_as_instance(&candidate);
py_func = py_data[BPY_DATA_CB_SLOT_POLL];
if (!is_write_ok)
if (!is_write_ok) {
pyrna_write_set(true);
}
args = PyTuple_New(2);
PyTuple_SET_ITEM(args, 0, py_self);
@@ -416,8 +423,9 @@ static bool bpy_prop_poll_cb(struct PointerRNA *self, PointerRNA candidate, stru
}
PyGILState_Release(gilstate);
if (!is_write_ok)
if (!is_write_ok) {
pyrna_write_set(false);
}
return result;
}
@@ -442,8 +450,9 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -458,15 +467,17 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
for (i = 0; i < len; ++i)
for (i = 0; i < len; ++i) {
values[i] = false;
}
}
else {
if (PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
for (i = 0; i < len; ++i)
for (i = 0; i < len; ++i) {
values[i] = false;
}
/* PyC_AsArray decrements refcount internally on error */
}
@@ -475,8 +486,9 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
}
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -504,8 +516,9 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -532,8 +545,9 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -560,8 +574,9 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -588,8 +603,9 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -617,8 +633,9 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -644,8 +661,9 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -672,8 +690,9 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -688,15 +707,17 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
for (i = 0; i < len; ++i)
for (i = 0; i < len; ++i) {
values[i] = 0;
}
}
else {
if (PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
for (i = 0; i < len; ++i)
for (i = 0; i < len; ++i) {
values[i] = 0;
}
/* PyC_AsArray decrements refcount internally on error */
}
@@ -705,8 +726,9 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
}
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -734,8 +756,9 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -762,8 +785,9 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -790,8 +814,9 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -818,8 +843,9 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -847,8 +873,9 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -874,8 +901,9 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -902,8 +930,9 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -918,15 +947,17 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
for (i = 0; i < len; ++i)
for (i = 0; i < len; ++i) {
values[i] = 0.0f;
}
}
else {
if (PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
for (i = 0; i < len; ++i)
for (i = 0; i < len; ++i) {
values[i] = 0.0f;
}
/* PyC_AsArray decrements refcount internally on error */
}
@@ -935,8 +966,9 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
}
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -964,8 +996,9 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -992,8 +1025,9 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1019,8 +1053,9 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1051,8 +1086,9 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1079,8 +1115,9 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1111,8 +1148,9 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1141,8 +1179,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -1155,8 +1194,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
PyErr_SetString(PyExc_ValueError, "the return value must be a string");
PyC_Err_PrintWithFunc(py_func);
}
else
else {
PyTuple_SET_ITEM(args, 1, py_value);
}
ret = PyObject_CallObject(py_func, args);
@@ -1174,8 +1214,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1202,8 +1243,9 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1230,8 +1272,9 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1259,8 +1302,9 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
use_gil = true; /* !PyC_IsInterpreterActive(); */
if (use_gil)
if (use_gil) {
gilstate = PyGILState_Ensure();
}
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -1286,8 +1330,9 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
Py_DECREF(ret);
}
if (use_gil)
if (use_gil) {
PyGILState_Release(gilstate);
}
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1423,8 +1468,9 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *
}
}
if (tmp_icon)
if (tmp_icon) {
tmp.icon = icon_id_from_name(tmp_icon);
}
items[i] = tmp;
@@ -2139,8 +2185,9 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
return NULL;
}
if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") == -1)
if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") == -1) {
return NULL;
}
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2155,7 +2202,9 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
// prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description);
prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
RNA_def_property_array(prop, size);
if (pydef) RNA_def_property_boolean_array_default(prop, def);
if (pydef) {
RNA_def_property_boolean_array_default(prop, def);
}
RNA_def_property_ui_text(prop, name ? name : id, description);
if (py_tags) {
@@ -2366,8 +2415,9 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
return NULL;
}
if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") == -1)
if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") == -1) {
return NULL;
}
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2381,7 +2431,9 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
prop = RNA_def_property(srna, id, PROP_INT, subtype);
RNA_def_property_array(prop, size);
if (pydef) RNA_def_property_int_array_default(prop, def);
if (pydef) {
RNA_def_property_int_array_default(prop, def);
}
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
@@ -2618,8 +2670,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
return NULL;
}
if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") == -1)
if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") == -1) {
return NULL;
}
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2633,7 +2686,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
prop = RNA_def_property(srna, id, PROP_FLOAT, subtype | unit);
RNA_def_property_array(prop, size);
if (pydef) RNA_def_property_float_array_default(prop, def);
if (pydef) {
RNA_def_property_float_array_default(prop, def);
}
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
@@ -2728,8 +2783,12 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
}
prop = RNA_def_property(srna, id, PROP_STRING, subtype);
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
if (def && def[0]) RNA_def_property_string_default(prop, def);
if (maxlen != 0) {
RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
}
if (def && def[0]) {
RNA_def_property_string_default(prop, def);
}
RNA_def_property_ui_text(prop, name ? name : id, description);
if (py_tags) {
@@ -2890,8 +2949,12 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
}
}
if (opts & PROP_ENUM_FLAG) prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description);
else prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description);
if (opts & PROP_ENUM_FLAG) {
prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description);
}
else {
prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description);
}
if (py_tags) {
RNA_def_property_tags(prop, prop_tags);
@@ -2994,8 +3057,9 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_CHECK(PointerProperty, property_flag_items);
ptype = pointer_type_from_py(type, "PointerProperty(...)");
if (!ptype)
if (!ptype) {
return NULL;
}
if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup) && !RNA_struct_is_ID(ptype)) {
PyErr_Format(PyExc_TypeError,
"PointerProperty(...) expected an RNA type derived from %.200s or %.200s",
@@ -3077,8 +3141,9 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items);
ptype = pointer_type_from_py(type, "CollectionProperty(...):");
if (!ptype)
if (!ptype) {
return NULL;
}
if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup)) {
PyErr_Format(

File diff suppressed because it is too large Load Diff

View File

@@ -339,8 +339,9 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
}
MEM_freeN((void *)path_full);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
}
return PyBool_FromLong(result);
}
@@ -356,8 +357,9 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
result = insert_keyframe(G_MAIN, depsgraph, &reports, id, NULL, group_name, path_full, index, cfra, keytype, NULL, options);
MEM_freeN((void *)path_full);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
}
return PyBool_FromLong(result);
}
@@ -452,8 +454,9 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
}
MEM_freeN((void *)path_full);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
}
return PyBool_FromLong(result);
}
@@ -466,8 +469,9 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
result = delete_keyframe(G.main, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
MEM_freeN((void *)path_full);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
}
return PyBool_FromLong(result);
}
@@ -493,8 +497,9 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
PYRNA_STRUCT_CHECK_OBJ(self);
if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index))
if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index)) {
return NULL;
}
if (pyrna_struct_anim_args_parse(
&self->ptr, "bpy_struct.driver_add():", path,
@@ -512,8 +517,9 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index,
CREATEDRIVER_WITH_FMODIFIER, DRIVER_TYPE_PYTHON);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
}
if (result) {
ID *id = self->ptr.id.data;
@@ -592,8 +598,9 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
MEM_freeN((void *)path_full);
}
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
}
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);

View File

@@ -276,8 +276,9 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
*
* arr[2][3][4] = x
* lvalue_dim = 2 */
for (i = lvalue_dim; i < totdim; i++)
for (i = lvalue_dim; i < totdim; i++) {
len *= dimsize[i];
}
}
if (tot != len) {
@@ -308,8 +309,9 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop,
if (MatrixObject_Check(rvalue)) {
MatrixObject *pymat = (MatrixObject *)rvalue;
if (BaseMath_ReadCallback(pymat) == -1)
if (BaseMath_ReadCallback(pymat) == -1) {
return -1;
}
if (RNA_property_type(prop) != PROP_FLOAT) {
PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign to non float array",
@@ -512,8 +514,9 @@ static int py_to_array_index(
lvalue_dim++;
for (i = lvalue_dim; i < totdim; i++)
for (i = lvalue_dim; i < totdim; i++) {
index *= dimsize[i];
}
index += arrayoffset;
@@ -751,8 +754,9 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop
for (i = 0; i < len; i++) {
PyObject *item;
if (dim + 1 < totdim)
if (dim + 1 < totdim) {
item = pyrna_py_from_array_internal(ptr, prop, dim + 1, index);
}
else {
item = pyrna_array_index(ptr, prop, *index);
*index = *index + 1;
@@ -802,8 +806,9 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
* x = arr[2][3]
* index = offset + 3 * 5 */
for (i = arraydim + 1; i < totdim; i++)
for (i = arraydim + 1; i < totdim; i++) {
index *= dimsize[i];
}
ret->arrayoffset = arrayoffset + index;
}
@@ -822,7 +827,9 @@ PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop)
ret = pyrna_math_object_from_array(ptr, prop);
/* is this a maths object? */
if (ret) return ret;
if (ret) {
return ret;
}
return pyrna_prop_CreatePyObject(ptr, prop);
}
@@ -834,8 +841,10 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
int type;
int i;
if (len == 0) /* possible with dynamic arrays */
if (len == 0) {
/* possible with dynamic arrays */
return 0;
}
if (RNA_property_array_dimension(ptr, prop, NULL) > 1) {
PyErr_SetString(PyExc_TypeError, "PropertyRNA - multi dimensional arrays not supported yet");
@@ -871,8 +880,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
if (tmp_arr != tmp)
if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
}
return i < len ? 1 : 0;
}
@@ -904,8 +914,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
if (tmp_arr != tmp)
if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
}
return i < len ? 1 : 0;
}
@@ -937,8 +948,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
if (tmp_arr != tmp)
if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
}
return i < len ? 1 : 0;
}

View File

@@ -136,8 +136,9 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
char *cb_event_str = NULL;
int cb_event;
if (!PyArg_ParseTuple(args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str))
if (!PyArg_ParseTuple(args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str)) {
return NULL;
}
if (!PyCallable_Check(cb_func)) {
PyErr_SetString(PyExc_TypeError, "callback_add(): first argument isn't callable");
@@ -174,8 +175,9 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
void *handle;
void *customdata;
if (!PyArg_ParseTuple(args, "O!:callback_remove", &PyCapsule_Type, &py_handle))
if (!PyArg_ParseTuple(args, "O!:callback_remove", &PyCapsule_Type, &py_handle)) {
return NULL;
}
handle = PyCapsule_GetPointer(py_handle, rna_capsual_id);
@@ -205,21 +207,21 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
/* reverse of rna_Space_refine() */
static eSpace_Type rna_Space_refine_reverse(StructRNA *srna)
{
if (srna == &RNA_SpaceView3D) return SPACE_VIEW3D;
if (srna == &RNA_SpaceGraphEditor) return SPACE_GRAPH;
if (srna == &RNA_SpaceOutliner) return SPACE_OUTLINER;
if (srna == &RNA_SpaceProperties) return SPACE_PROPERTIES;
if (srna == &RNA_SpaceFileBrowser) return SPACE_FILE;
if (srna == &RNA_SpaceImageEditor) return SPACE_IMAGE;
if (srna == &RNA_SpaceInfo) return SPACE_INFO;
if (srna == &RNA_SpaceSequenceEditor) return SPACE_SEQ;
if (srna == &RNA_SpaceTextEditor) return SPACE_TEXT;
if (srna == &RNA_SpaceDopeSheetEditor) return SPACE_ACTION;
if (srna == &RNA_SpaceNLA) return SPACE_NLA;
if (srna == &RNA_SpaceNodeEditor) return SPACE_NODE;
if (srna == &RNA_SpaceConsole) return SPACE_CONSOLE;
if (srna == &RNA_SpacePreferences) return SPACE_USERPREF;
if (srna == &RNA_SpaceClipEditor) return SPACE_CLIP;
if (srna == &RNA_SpaceView3D) { return SPACE_VIEW3D; }
if (srna == &RNA_SpaceGraphEditor) { return SPACE_GRAPH; }
if (srna == &RNA_SpaceOutliner) { return SPACE_OUTLINER; }
if (srna == &RNA_SpaceProperties) { return SPACE_PROPERTIES; }
if (srna == &RNA_SpaceFileBrowser) { return SPACE_FILE; }
if (srna == &RNA_SpaceImageEditor) { return SPACE_IMAGE; }
if (srna == &RNA_SpaceInfo) { return SPACE_INFO; }
if (srna == &RNA_SpaceSequenceEditor) { return SPACE_SEQ; }
if (srna == &RNA_SpaceTextEditor) { return SPACE_TEXT; }
if (srna == &RNA_SpaceDopeSheetEditor) { return SPACE_ACTION; }
if (srna == &RNA_SpaceNLA) { return SPACE_NLA; }
if (srna == &RNA_SpaceNodeEditor) { return SPACE_NODE; }
if (srna == &RNA_SpaceConsole) { return SPACE_CONSOLE; }
if (srna == &RNA_SpacePreferences) { return SPACE_USERPREF; }
if (srna == &RNA_SpaceClipEditor) { return SPACE_CLIP; }
return SPACE_EMPTY;
}

View File

@@ -58,17 +58,20 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
/* new style errors. `err' is an instance */
*message = _PyObject_GetAttrId(err, &PyId_msg);
if (!*message)
if (!*message) {
goto finally;
}
v = _PyObject_GetAttrId(err, &PyId_filename);
if (!v)
if (!v) {
goto finally;
}
if (v == Py_None) {
Py_DECREF(v);
*filename = _PyUnicode_FromId(&PyId_string);
if (*filename == NULL)
if (*filename == NULL) {
goto finally;
}
Py_INCREF(*filename);
}
else {
@@ -76,31 +79,36 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
}
v = _PyObject_GetAttrId(err, &PyId_lineno);
if (!v)
if (!v) {
goto finally;
}
hold = PyLong_AsLong(v);
Py_DECREF(v);
if (hold < 0 && PyErr_Occurred())
if (hold < 0 && PyErr_Occurred()) {
goto finally;
}
*lineno = (int)hold;
v = _PyObject_GetAttrId(err, &PyId_offset);
if (!v)
if (!v) {
goto finally;
}
if (v == Py_None) {
*offset = -1;
Py_DECREF(v);
} else {
hold = PyLong_AsLong(v);
Py_DECREF(v);
if (hold < 0 && PyErr_Occurred())
if (hold < 0 && PyErr_Occurred()) {
goto finally;
}
*offset = (int)hold;
}
v = _PyObject_GetAttrId(err, &PyId_text);
if (!v)
if (!v) {
goto finally;
}
if (v == Py_None) {
Py_DECREF(v);
*text = NULL;