Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/python/intern/bpy_rna.c')
-rw-r--r--source/blender/python/intern/bpy_rna.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 316cfe4d8b1..16e90a55844 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -5897,28 +5897,37 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
break;
case PROP_STRING: {
const char *data_ch;
- PyObject *value_coerce = NULL;
const int subtype = RNA_property_subtype(prop);
+ size_t data_ch_len;
- if (flag & PROP_THICK_WRAP) {
- data_ch = (char *)data;
+ if (flag & PROP_DYNAMIC) {
+ ParameterDynAlloc *data_alloc = data;
+ data_ch = data_alloc->array;
+ data_ch_len = data_alloc->array_tot;
+ BLI_assert((data_ch == NULL) || strlen(data_ch) == data_ch_len);
}
else {
- data_ch = *(char **)data;
+ data_ch = (flag & PROP_THICK_WRAP) ? (char *)data : *(char **)data;
+ data_ch_len = data_ch ? strlen(data_ch) : 0;
}
+ if (UNLIKELY(data_ch == NULL)) {
+ BLI_assert((flag & PROP_NEVER_NULL) == 0);
+ ret = Py_None;
+ Py_INCREF(ret);
+ }
#ifdef USE_STRING_COERCE
- if (subtype == PROP_BYTESTRING) {
- ret = PyBytes_FromString(data_ch);
+ else if (subtype == PROP_BYTESTRING) {
+ ret = PyBytes_FromStringAndSize(data_ch, data_ch_len);
}
else if (ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
- ret = PyC_UnicodeFromByte(data_ch);
+ ret = PyC_UnicodeFromByteAndSize(data_ch, data_ch_len);
}
else {
- ret = PyUnicode_FromString(data_ch);
+ ret = PyUnicode_FromStringAndSize(data_ch, data_ch_len);
}
#else
- if (subtype == PROP_BYTESTRING) {
+ else if (subtype == PROP_BYTESTRING) {
ret = PyBytes_FromString(buf);
}
else {
@@ -5926,10 +5935,6 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
}
#endif
-#ifdef USE_STRING_COERCE
- Py_XDECREF(value_coerce);
-#endif
-
break;
}
case PROP_ENUM: {
@@ -6229,7 +6234,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
arg_name = PyUnicode_AsUTF8(key);
found = false;
- if (arg_name == NULL) { /* Unlikely the argname is not a string, but ignore if it is. */
+ if (arg_name == NULL) { /* Unlikely the `arg_name` is not a string, but ignore if it is. */
PyErr_Clear();
}
else {