diff options
Diffstat (limited to 'source/blender/python/intern/bpy_props.c')
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index bb116017f6b..bd033736865 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -75,9 +75,10 @@ static EnumPropertyItem property_flag_enum_items[] = { static EnumPropertyItem property_subtype_string_items[] = { {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, {PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""}, - {PROP_FILENAME, "FILENAME", 0, "Filename", ""}, + {PROP_FILENAME, "FILE_NAME", 0, "Filename", ""}, {PROP_BYTESTRING, "BYTE_STRING", 0, "Byte String", ""}, {PROP_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {PROP_PASSWORD, "PASSWORD", 0, "Password", 0}, {PROP_NONE, "NONE", 0, "None", ""}, {0, NULL, 0, NULL, NULL}}; @@ -260,7 +261,7 @@ static int bpy_prop_callback_check(PyObject *py_func, int argcount) static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_cb) { /* assume this is already checked for type and arg length */ - if (update_cb) { + if (update_cb && update_cb != Py_None) { PyObject **py_data = MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, __func__); RNA_def_property_update_runtime(prop, (void *)bpy_prop_update_cb); py_data[BPY_DATA_CB_SLOT_UPDATE] = update_cb; @@ -309,35 +310,38 @@ static int py_long_as_int(PyObject *py_long, int *r_int) /* terse macros for error checks shared between all funcs cant use function * calls because of static strings passed to pyrna_set_to_enum_bitfield */ #define BPY_PROPDEF_CHECK(_func, _property_flag_items) \ - if (id_len >= MAX_IDPROP_NAME) { \ + if (UNLIKELY(id_len >= MAX_IDPROP_NAME)) { \ PyErr_Format(PyExc_TypeError, \ #_func"(): '%.200s' too long, max length is %d", \ id, MAX_IDPROP_NAME - 1); \ return NULL; \ } \ - if (RNA_def_property_free_identifier(srna, id) == -1) { \ + if (UNLIKELY(RNA_def_property_free_identifier(srna, id) == -1)) { \ PyErr_Format(PyExc_TypeError, \ #_func"(): '%s' is defined as a non-dynamic type", \ id); \ return NULL; \ } \ - if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, \ + if (UNLIKELY(pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, \ pyopts, \ &opts, \ - #_func"(options={ ...}):")) \ + #_func"(options={ ...}):"))) \ { \ return NULL; \ } (void)0 #define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ BPY_PROPDEF_CHECK(_func, _property_flag_items); \ - if (pysubtype && RNA_enum_value_from_id(_subtype, \ + if (UNLIKELY(pysubtype && RNA_enum_value_from_id(_subtype, \ pysubtype, \ - &subtype) == 0) \ + &subtype) == 0)) \ { \ + const char *enum_str = BPy_enum_as_string(_subtype); \ PyErr_Format(PyExc_TypeError, \ - #_func"(subtype='%s'): invalid subtype", \ - pysubtype); \ + #_func"(subtype='%s'): " \ + "subtype not found in (%s)", \ + pysubtype, enum_str); \ + MEM_freeN((void *)enum_str); \ return NULL; \ } (void)0 @@ -921,7 +925,7 @@ BPY_PROPDEF_NAME_DOC BPY_PROPDEF_DESC_DOC " :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE', 'LIBRARY_EDITABLE'].\n" " :type options: set\n" -" :arg subtype: Enumerator in ['FILE_PATH', 'DIR_PATH', 'FILENAME', 'NONE'].\n" +" :arg subtype: Enumerator in ['FILE_PATH', 'DIR_PATH', 'FILE_NAME', 'NONE'].\n" " :type subtype: string\n" BPY_PROPDEF_UPDATE_DOC ); @@ -1511,7 +1515,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw args = PyTuple_New(0); ret = BPy_RemoveProperty(self, args, kw); Py_DECREF(args); - return ret; + return ret; } else if (PyTuple_GET_SIZE(args) > 1) { PyErr_SetString(PyExc_ValueError, "all args must be keywords"); |