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:
authorCampbell Barton <ideasman42@gmail.com>2021-02-13 14:57:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-02-13 15:09:55 +0300
commitdae445d94a7a5e1ad38719ea05e5bb0bc76ede84 (patch)
tree5f174cb170079ac62eaf521cb3cec2535162e6bf /source/blender/python/generic
parent32660201acaa1138c0fed6ef3fa38f69daa3dac3 (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')
-rw-r--r--source/blender/python/generic/idprop_py_api.c16
-rw-r--r--source/blender/python/generic/imbuf_py_api.c2
-rw-r--r--source/blender/python/generic/py_capi_utils.c22
3 files changed, 20 insertions, 20 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);
diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c
index d05690759ce..fe72f267a5d 100644
--- a/source/blender/python/generic/imbuf_py_api.c
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -267,7 +267,7 @@ static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(c
ImBuf *ibuf = self->ibuf;
const Py_ssize_t value_str_len_max = sizeof(ibuf->name);
Py_ssize_t value_str_len;
- const char *value_str = _PyUnicode_AsStringAndSize(value, &value_str_len);
+ const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len);
if (value_str_len >= value_str_len_max) {
PyErr_Format(PyExc_TypeError, "filepath length over %zd", value_str_len_max - 1);
return -1;
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 1eb4a51c392..c7ce264f2f9 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -257,7 +257,7 @@ int PyC_ParseBool(PyObject *o, void *p)
int PyC_ParseStringEnum(PyObject *o, void *p)
{
struct PyC_StringEnum *e = p;
- const char *value = _PyUnicode_AsString(o);
+ const char *value = PyUnicode_AsUTF8(o);
if (value == NULL) {
PyErr_Format(PyExc_ValueError, "expected a string, got %s", Py_TYPE(o)->tp_name);
return 0;
@@ -343,7 +343,7 @@ void PyC_ObSpitStr(char *result, size_t result_len, PyObject *var)
(int)var->ob_refcnt,
(void *)var,
type ? type->tp_name : null_str,
- var_str ? _PyUnicode_AsString(var_str) : "<error>");
+ var_str ? PyUnicode_AsUTF8(var_str) : "<error>");
if (var_str != NULL) {
Py_DECREF(var_str);
}
@@ -405,7 +405,7 @@ void PyC_FileAndNum(const char **r_filename, int *r_lineno)
/* when executing a script */
if (r_filename) {
- *r_filename = _PyUnicode_AsString(frame->f_code->co_filename);
+ *r_filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
}
/* when executing a module */
@@ -418,7 +418,7 @@ void PyC_FileAndNum(const char **r_filename, int *r_lineno)
if (mod) {
PyObject *mod_file = PyModule_GetFilenameObject(mod);
if (mod_file) {
- *r_filename = _PyUnicode_AsString(mod_name);
+ *r_filename = PyUnicode_AsUTF8(mod_name);
Py_DECREF(mod_file);
}
else {
@@ -428,7 +428,7 @@ void PyC_FileAndNum(const char **r_filename, int *r_lineno)
/* unlikely, fallback */
if (*r_filename == NULL) {
- *r_filename = _PyUnicode_AsString(mod_name);
+ *r_filename = PyUnicode_AsUTF8(mod_name);
}
}
}
@@ -569,9 +569,9 @@ void PyC_Err_PrintWithFunc(PyObject *py_func)
/* use py style error */
fprintf(stderr,
"File \"%s\", line %d, in %s\n",
- _PyUnicode_AsString(f_code->co_filename),
+ PyUnicode_AsUTF8(f_code->co_filename),
f_code->co_firstlineno,
- _PyUnicode_AsString(((PyFunctionObject *)py_func)->func_name));
+ PyUnicode_AsUTF8(((PyFunctionObject *)py_func)->func_name));
}
/** \} */
@@ -740,7 +740,7 @@ const char *PyC_UnicodeAsByteAndSize(PyObject *py_str, Py_ssize_t *size, PyObjec
{
const char *result;
- result = _PyUnicode_AsStringAndSize(py_str, size);
+ result = PyUnicode_AsUTF8AndSize(py_str, size);
if (result) {
/* 99% of the time this is enough but we better support non unicode
@@ -767,7 +767,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
{
const char *result;
- result = _PyUnicode_AsString(py_str);
+ result = PyUnicode_AsUTF8(py_str);
if (result) {
/* 99% of the time this is enough but we better support non unicode
@@ -1146,7 +1146,7 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items,
*r_value = 0;
while (_PySet_NextEntry(value, &pos, &key, &hash)) {
- const char *param = _PyUnicode_AsString(key);
+ const char *param = PyUnicode_AsUTF8(key);
if (param == NULL) {
PyErr_Format(PyExc_TypeError,
@@ -1324,7 +1324,7 @@ bool PyC_RunString_AsStringAndSize(const char *imports[],
const char *val;
Py_ssize_t val_len;
- val = _PyUnicode_AsStringAndSize(retval, &val_len);
+ val = PyUnicode_AsUTF8AndSize(retval, &val_len);
if (val == NULL && PyErr_Occurred()) {
ok = false;
}