diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-02-13 14:57:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-02-13 15:09:55 +0300 |
commit | dae445d94a7a5e1ad38719ea05e5bb0bc76ede84 (patch) | |
tree | 5f174cb170079ac62eaf521cb3cec2535162e6bf /source/blender/python/generic/idprop_py_api.c | |
parent | 32660201acaa1138c0fed6ef3fa38f69daa3dac3 (diff) |
Fix T85573: Building with Python 3.10a5 fails
Replace deprecated _PyUnicode_AsString{AndSize} usage.
T83626 still needs to be resolved before 3.10 is usable.
Diffstat (limited to 'source/blender/python/generic/idprop_py_api.c')
-rw-r--r-- | source/blender/python/generic/idprop_py_api.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 6be7348a2f8..c329ea7965c 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -189,13 +189,13 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject st = (char *)PyC_UnicodeAsByte(value, &value_coerce); alloc_len = strlen(st) + 1; - st = _PyUnicode_AsString(value); + st = PyUnicode_AsUTF8(value); IDP_ResizeArray(prop, alloc_len); memcpy(IDP_Array(prop), st, alloc_len); Py_XDECREF(value_coerce); } # else - st = _PyUnicode_AsString(value); + st = PyUnicode_AsUTF8(value); IDP_ResizeArray(prop, strlen(st) + 1); strcpy(IDP_Array(prop), st); # endif @@ -253,7 +253,7 @@ static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUS return -1; } - name = _PyUnicode_AsStringAndSize(value, &name_size); + name = PyUnicode_AsUTF8AndSize(value, &name_size); if (name_size >= MAX_IDPROP_NAME) { PyErr_SetString(PyExc_TypeError, "string length cannot exceed 63 characters!"); @@ -300,7 +300,7 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item) return NULL; } - name = _PyUnicode_AsString(item); + name = PyUnicode_AsUTF8(item); if (name == NULL) { PyErr_SetString(PyExc_TypeError, "only strings are allowed as keys of ID properties"); @@ -358,7 +358,7 @@ static const char *idp_try_read_name(PyObject *name_obj) const char *name = NULL; if (name_obj) { Py_ssize_t name_size; - name = _PyUnicode_AsStringAndSize(name_obj, &name_size); + name = PyUnicode_AsUTF8AndSize(name_obj, &name_size); if (name == NULL) { PyErr_Format(PyExc_KeyError, @@ -420,7 +420,7 @@ static IDProperty *idp_from_PyUnicode(const char *name, PyObject *ob) prop = IDP_New(IDP_STRING, &val, name); Py_XDECREF(value_coerce); #else - val.str = _PyUnicode_AsString(ob); + val.str = PyUnicode_AsUTF8(ob); prop = IDP_New(IDP_STRING, val, name); #endif return prop; @@ -722,7 +722,7 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) if (val == NULL) { /* del idprop[key] */ IDProperty *pkey; - const char *name = _PyUnicode_AsString(key); + const char *name = PyUnicode_AsUTF8(key); if (name == NULL) { PyErr_Format(PyExc_KeyError, "expected a string, not %.200s", Py_TYPE(key)->tp_name); @@ -1050,7 +1050,7 @@ static PyObject *BPy_IDGroup_items(BPy_IDProperty *self) static int BPy_IDGroup_Contains(BPy_IDProperty *self, PyObject *value) { - const char *name = _PyUnicode_AsString(value); + const char *name = PyUnicode_AsUTF8(value); if (!name) { PyErr_Format(PyExc_TypeError, "expected a string, not a %.200s", Py_TYPE(value)->tp_name); |