[Bf-blender-cvs] [dae445d94a7] master: Fix T85573: Building with Python 3.10a5 fails

Campbell Barton noreply at git.blender.org
Sat Feb 13 13:11:35 CET 2021


Commit: dae445d94a7a5e1ad38719ea05e5bb0bc76ede84
Author: Campbell Barton
Date:   Sat Feb 13 22:57:01 2021 +1100
Branches: master
https://developer.blender.org/rBdae445d94a7a5e1ad38719ea05e5bb0bc76ede84

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.

===================================================================

M	intern/cycles/blender/blender_python.cpp
M	source/blender/freestyle/intern/python/BPy_SShape.cpp
M	source/blender/python/bmesh/bmesh_py_ops.c
M	source/blender/python/bmesh/bmesh_py_ops_call.c
M	source/blender/python/bmesh/bmesh_py_types_customdata.c
M	source/blender/python/generic/idprop_py_api.c
M	source/blender/python/generic/imbuf_py_api.c
M	source/blender/python/generic/py_capi_utils.c
M	source/blender/python/gpu/gpu_py_api.c
M	source/blender/python/gpu/gpu_py_vertex_format.c
M	source/blender/python/intern/bpy.c
M	source/blender/python/intern/bpy_app_translations.c
M	source/blender/python/intern/bpy_capi_utils.c
M	source/blender/python/intern/bpy_driver.c
M	source/blender/python/intern/bpy_interface.c
M	source/blender/python/intern/bpy_library_load.c
M	source/blender/python/intern/bpy_msgbus.c
M	source/blender/python/intern/bpy_operator.c
M	source/blender/python/intern/bpy_operator_wrap.c
M	source/blender/python/intern/bpy_props.c
M	source/blender/python/intern/bpy_rna.c
M	source/blender/python/intern/bpy_traceback.c
M	source/blender/python/mathutils/mathutils_Euler.c
M	source/blender/python/mathutils/mathutils_Matrix.c
M	source/blender/python/mathutils/mathutils_Quaternion.c

===================================================================

diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 5646bd5b2eb..0daad310543 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -147,7 +147,7 @@ void python_thread_state_restore(void **python_thread_state)
 
 static const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
 {
-  const char *result = _PyUnicode_AsString(py_str);
+  const char *result = PyUnicode_AsUTF8(py_str);
   if (result) {
     /* 99% of the time this is enough but we better support non unicode
      * chars since blender doesn't limit this.
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp
index f43a464d99e..0ea02d8a3f6 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp
@@ -201,7 +201,7 @@ static int SShape_name_set(BPy_SShape *self, PyObject *value, void *UNUSED(closu
     PyErr_SetString(PyExc_TypeError, "value must be a string");
     return -1;
   }
-  const char *name = _PyUnicode_AsString(value);
+  const char *name = PyUnicode_AsUTF8(value);
   self->ss->setName(name);
   return 0;
 }
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index c5d72a00ce3..b23891ca1fe 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -245,7 +245,7 @@ static PyTypeObject bmesh_op_Type = {
 
 static PyObject *bpy_bmesh_ops_module_getattro(PyObject *UNUSED(self), PyObject *pyname)
 {
-  const char *opname = _PyUnicode_AsString(pyname);
+  const char *opname = PyUnicode_AsUTF8(pyname);
 
   if (BMO_opcode_from_opname(opname) != -1) {
     return bpy_bmesh_op_CreatePyObject(opname);
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index d0676ec1947..28daf08507d 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -184,7 +184,7 @@ static int bpy_slot_from_py(BMesh *bm,
       if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) {
         int enum_val = -1;
         PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_data.flags;
-        const char *enum_str = _PyUnicode_AsString(value);
+        const char *enum_str = PyUnicode_AsUTF8(value);
 
         if (enum_str == NULL) {
           PyErr_Format(PyExc_TypeError,
@@ -787,7 +787,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
     PyObject *key, *value;
     Py_ssize_t pos = 0;
     while (PyDict_Next(kw, &pos, &key, &value)) {
-      const char *slot_name = _PyUnicode_AsString(key);
+      const char *slot_name = PyUnicode_AsUTF8(key);
       BMOpSlot *slot;
 
       if (!BMO_slot_exists(bmop.slots_in, slot_name)) {
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index 96c36f2d788..471a311c411 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -804,7 +804,7 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
 {
   /* don't need error check here */
   if (PyUnicode_Check(key)) {
-    return bpy_bmlayercollection_subscript_str(self, _PyUnicode_AsString(key));
+    return bpy_bmlayercollection_subscript_str(self, PyUnicode_AsUTF8(key));
   }
   if (PyIndex_Check(key)) {
     const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
@@ -862,7 +862,7 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
 
 static int bpy_bmlayercollection_contains(BPy_BMLayerCollection *self, PyObject *value)
 {
-  const char *keyname = _PyUnicode_AsString(value);
+  const char *keyname = PyUnicode_AsUTF8(value);
   CustomData *data;
   int index;
 
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);
+  resul

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list