diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index a2521484c88..2b4dcf93b66 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -760,7 +760,6 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int *valu return 0; } -/* 'value' _must_ be a set type, error check before calling */ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix) { /* set of enum items, concatenate all values with OR */ @@ -771,6 +770,15 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, co Py_ssize_t hash = 0; PyObject *key; + PyC_ObSpit("", value); + + if (!PySet_Check(value)) { + PyErr_Format(PyExc_TypeError, + "%.200s expected a set, not %.200s", + error_prefix, Py_TYPE(value)->tp_name); + return -1; + } + *r_value = 0; while (_PySet_NextEntry(value, &pos, &key, &hash)) { @@ -778,7 +786,7 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, co if (param == NULL) { PyErr_Format(PyExc_TypeError, - "%.200s expected a string, not %.200s", + "%.200s set must contain strings, not %.200s", error_prefix, Py_TYPE(key)->tp_name); return -1; }