pyapi internal api code: check for == -1 rather then < 0, for known error returns.
This commit is contained in:
@@ -182,7 +182,7 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *clos
|
||||
const int flag = GET_INT_FROM_POINTER(closure);
|
||||
const int param = PyObject_IsTrue(value);
|
||||
|
||||
if (param < 0) {
|
||||
if (param == -1) {
|
||||
PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
|
||||
return -1;
|
||||
}
|
||||
|
@@ -388,7 +388,7 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
|
||||
values[i] = false;
|
||||
}
|
||||
else {
|
||||
if (PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") < 0) {
|
||||
if (PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") == -1) {
|
||||
printf_func_error(py_func);
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
@@ -622,7 +622,7 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
|
||||
values[i] = 0;
|
||||
}
|
||||
else {
|
||||
if (PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") < 0) {
|
||||
if (PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") == -1) {
|
||||
printf_func_error(py_func);
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
@@ -856,7 +856,7 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
|
||||
values[i] = 0.0f;
|
||||
}
|
||||
else {
|
||||
if (PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") < 0) {
|
||||
if (PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") == -1) {
|
||||
printf_func_error(py_func);
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
@@ -1941,7 +1941,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") < 0)
|
||||
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) {
|
||||
@@ -2136,7 +2136,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") < 0)
|
||||
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) {
|
||||
@@ -2356,7 +2356,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") < 0)
|
||||
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) {
|
||||
|
@@ -1187,7 +1187,7 @@ int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) < 0) {
|
||||
if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1682,13 +1682,13 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
|
||||
/* type checkins is done by each function */
|
||||
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
|
||||
/* set of enum items, concatenate all values with OR */
|
||||
if (pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) < 0) {
|
||||
if (pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* simple enum string */
|
||||
if (pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) < 0) {
|
||||
if (pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -4384,7 +4384,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
|
||||
bool attr_signed;
|
||||
RawPropertyType raw_type;
|
||||
|
||||
if (foreach_parse_args(self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) < 0)
|
||||
if (foreach_parse_args(self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) == -1)
|
||||
return NULL;
|
||||
|
||||
if (tot == 0)
|
||||
|
@@ -160,14 +160,14 @@ static int pyrna_struct_keyframe_parse(
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) < 0)
|
||||
if (pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) == -1)
|
||||
return -1;
|
||||
|
||||
if (*cfra == FLT_MAX)
|
||||
*cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
|
||||
|
||||
/* flag may be null (no option currently for remove keyframes e.g.). */
|
||||
if (pyoptions && options && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) < 0))
|
||||
if (pyoptions && options && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1))
|
||||
return -1;
|
||||
|
||||
return 0; /* success */
|
||||
@@ -301,7 +301,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
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, &path_full, &index) < 0) {
|
||||
if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -377,7 +377,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "s|i:driver_remove", &path, &index))
|
||||
return NULL;
|
||||
|
||||
if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) < 0) {
|
||||
if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
@@ -101,7 +101,7 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
|
||||
|
||||
if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
|
||||
if (cb_event_str) {
|
||||
if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0) {
|
||||
if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") == -1) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -212,10 +212,10 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0) {
|
||||
if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_add()") < 0) {
|
||||
else if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_add()") == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -278,7 +278,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
|
||||
customdata = ED_region_draw_cb_customdata(handle);
|
||||
Py_DECREF((PyObject *)customdata);
|
||||
|
||||
if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_remove()") < 0) {
|
||||
if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_remove()") == -1) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user