0009_python3_10.patch 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  1. commit 5a4f5d69d90dc497e7a0dd8df56e7b3757edf6d4
  2. Author: CYBERDEViL <cyberdevil@notabug.org>
  3. Date: Sat Dec 16 00:33:17 2023 +0100
  4. python3.10: "Fix T85573: Building with Python 3.10a5 fails"
  5. Adjusted Blender upstream ref: dae445d94a7a5e1ad38719ea05e5bb0bc76ede84
  6. Command used:
  7. grep -rIlZ _PyUnicode_AsString ./blender-2.79b/ | xargs -0 sed -i 's/_PyUnicode_AsString/PyUnicode_AsUTF8/g'
  8. commit 5009c95b82cab0bddefce14d915303634c7369ee
  9. Author: CYBERDEViL <cyberdevil@notabug.org>
  10. Date: Sat Dec 16 00:30:30 2023 +0100
  11. python3.10: "PyAPI: resolve build error with Python 3.10"
  12. Fully applied Blender upstream ref: 6fe00939b0a471cc149ea5b3c63ca57b049b4a37
  13. diff --git a/blender-2.79b/intern/cycles/blender/blender_python.cpp b/blender-2.79b/intern/cycles/blender/blender_python.cpp
  14. index bee6dd1..88fbf8a 100644
  15. --- a/blender-2.79b/intern/cycles/blender/blender_python.cpp
  16. +++ b/blender-2.79b/intern/cycles/blender/blender_python.cpp
  17. @@ -141,7 +141,7 @@ void python_thread_state_restore(void **python_thread_state)
  18. static const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
  19. {
  20. - const char *result = _PyUnicode_AsString(py_str);
  21. + const char *result = PyUnicode_AsUTF8(py_str);
  22. if(result) {
  23. /* 99% of the time this is enough but we better support non unicode
  24. * chars since blender doesnt limit this.
  25. diff --git a/blender-2.79b/source/blender/freestyle/intern/python/BPy_SShape.cpp b/blender-2.79b/source/blender/freestyle/intern/python/BPy_SShape.cpp
  26. index 9169adf..eabfc07 100644
  27. --- a/blender-2.79b/source/blender/freestyle/intern/python/BPy_SShape.cpp
  28. +++ b/blender-2.79b/source/blender/freestyle/intern/python/BPy_SShape.cpp
  29. @@ -194,7 +194,7 @@ static int SShape_name_set(BPy_SShape *self, PyObject *value, void *UNUSED(closu
  30. PyErr_SetString(PyExc_TypeError, "value must be a string");
  31. return -1;
  32. }
  33. - const char *name = _PyUnicode_AsString(value);
  34. + const char *name = PyUnicode_AsUTF8(value);
  35. self->ss->setName(name);
  36. return 0;
  37. }
  38. diff --git a/blender-2.79b/source/blender/python/bmesh/bmesh_py_ops.c b/blender-2.79b/source/blender/python/bmesh/bmesh_py_ops.c
  39. index ea37159..8543c8f 100644
  40. --- a/blender-2.79b/source/blender/python/bmesh/bmesh_py_ops.c
  41. +++ b/blender-2.79b/source/blender/python/bmesh/bmesh_py_ops.c
  42. @@ -220,7 +220,7 @@ static PyTypeObject bmesh_op_Type = {
  43. static PyObject *bpy_bmesh_ops_fakemod_getattro(PyObject *UNUSED(self), PyObject *pyname)
  44. {
  45. - const char *opname = _PyUnicode_AsString(pyname);
  46. + const char *opname = PyUnicode_AsUTF8(pyname);
  47. if (BMO_opcode_from_opname(opname) != -1) {
  48. return bpy_bmesh_op_CreatePyObject(opname);
  49. diff --git a/blender-2.79b/source/blender/python/bmesh/bmesh_py_ops_call.c b/blender-2.79b/source/blender/python/bmesh/bmesh_py_ops_call.c
  50. index 8f28791..7f2cab3 100644
  51. --- a/blender-2.79b/source/blender/python/bmesh/bmesh_py_ops_call.c
  52. +++ b/blender-2.79b/source/blender/python/bmesh/bmesh_py_ops_call.c
  53. @@ -724,7 +724,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
  54. PyObject *key, *value;
  55. Py_ssize_t pos = 0;
  56. while (PyDict_Next(kw, &pos, &key, &value)) {
  57. - const char *slot_name = _PyUnicode_AsString(key);
  58. + const char *slot_name = PyUnicode_AsUTF8(key);
  59. BMOpSlot *slot;
  60. if (!BMO_slot_exists(bmop.slots_in, slot_name)) {
  61. diff --git a/blender-2.79b/source/blender/python/bmesh/bmesh_py_types_customdata.c b/blender-2.79b/source/blender/python/bmesh/bmesh_py_types_customdata.c
  62. index 908f6b5..9b0d7b9 100644
  63. --- a/blender-2.79b/source/blender/python/bmesh/bmesh_py_types_customdata.c
  64. +++ b/blender-2.79b/source/blender/python/bmesh/bmesh_py_types_customdata.c
  65. @@ -658,7 +658,7 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
  66. {
  67. /* don't need error check here */
  68. if (PyUnicode_Check(key)) {
  69. - return bpy_bmlayercollection_subscript_str(self, _PyUnicode_AsString(key));
  70. + return bpy_bmlayercollection_subscript_str(self, PyUnicode_AsUTF8(key));
  71. }
  72. else if (PyIndex_Check(key)) {
  73. Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
  74. @@ -712,7 +712,7 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
  75. static int bpy_bmlayercollection_contains(BPy_BMLayerCollection *self, PyObject *value)
  76. {
  77. - const char *keyname = _PyUnicode_AsString(value);
  78. + const char *keyname = PyUnicode_AsUTF8(value);
  79. CustomData *data;
  80. int index;
  81. diff --git a/blender-2.79b/source/blender/python/generic/bpy_internal_import.c b/blender-2.79b/source/blender/python/generic/bpy_internal_import.c
  82. index 7ab6447..78f7b84 100644
  83. --- a/blender-2.79b/source/blender/python/generic/bpy_internal_import.c
  84. +++ b/blender-2.79b/source/blender/python/generic/bpy_internal_import.c
  85. @@ -253,7 +253,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
  86. if (module_file == NULL) {
  87. return NULL;
  88. }
  89. - filepath = (char *)_PyUnicode_AsString(module_file);
  90. + filepath = (char *)PyUnicode_AsUTF8(module_file);
  91. Py_DECREF(module_file);
  92. if (filepath == NULL) {
  93. return NULL;
  94. diff --git a/blender-2.79b/source/blender/python/generic/idprop_py_api.c b/blender-2.79b/source/blender/python/generic/idprop_py_api.c
  95. index 576f114..a8fea1d 100644
  96. --- a/blender-2.79b/source/blender/python/generic/idprop_py_api.c
  97. +++ b/blender-2.79b/source/blender/python/generic/idprop_py_api.c
  98. @@ -181,13 +181,13 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
  99. st = (char *)PyC_UnicodeAsByte(value, &value_coerce);
  100. alloc_len = strlen(st) + 1;
  101. - st = _PyUnicode_AsString(value);
  102. + st = PyUnicode_AsUTF8(value);
  103. IDP_ResizeArray(prop, alloc_len);
  104. memcpy(IDP_Array(prop), st, alloc_len);
  105. Py_XDECREF(value_coerce);
  106. }
  107. #else
  108. - st = _PyUnicode_AsString(value);
  109. + st = PyUnicode_AsUTF8(value);
  110. IDP_ResizeArray(prop, strlen(st) + 1);
  111. strcpy(IDP_Array(prop), st);
  112. #endif
  113. @@ -248,7 +248,7 @@ static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUS
  114. return -1;
  115. }
  116. - name = _PyUnicode_AsStringAndSize(value, &name_size);
  117. + name = PyUnicode_AsUTF8AndSize(value, &name_size);
  118. if (name_size > MAX_IDPROP_NAME) {
  119. PyErr_SetString(PyExc_TypeError, "string length cannot exceed 63 characters!");
  120. @@ -291,7 +291,7 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item)
  121. return NULL;
  122. }
  123. - name = _PyUnicode_AsString(item);
  124. + name = PyUnicode_AsUTF8(item);
  125. if (name == NULL) {
  126. PyErr_SetString(PyExc_TypeError, "only strings are allowed as keys of ID properties");
  127. @@ -349,7 +349,7 @@ static const char *idp_try_read_name(PyObject *name_obj)
  128. const char *name = NULL;
  129. if (name_obj) {
  130. Py_ssize_t name_size;
  131. - name = _PyUnicode_AsStringAndSize(name_obj, &name_size);
  132. + name = PyUnicode_AsUTF8AndSize(name_obj, &name_size);
  133. if (name == NULL) {
  134. PyErr_Format(PyExc_KeyError,
  135. @@ -406,7 +406,7 @@ static IDProperty *idp_from_PyUnicode(const char *name, PyObject *ob)
  136. prop = IDP_New(IDP_STRING, &val, name);
  137. Py_XDECREF(value_coerce);
  138. #else
  139. - val.str = _PyUnicode_AsString(ob);
  140. + val.str = PyUnicode_AsUTF8(ob);
  141. prop = IDP_New(IDP_STRING, val, name);
  142. #endif
  143. return prop;
  144. @@ -693,7 +693,7 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
  145. if (val == NULL) { /* del idprop[key] */
  146. IDProperty *pkey;
  147. - const char *name = _PyUnicode_AsString(key);
  148. + const char *name = PyUnicode_AsUTF8(key);
  149. if (name == NULL) {
  150. PyErr_Format(PyExc_KeyError,
  151. @@ -867,7 +867,7 @@ static PyObject *BPy_IDGroup_pop(BPy_IDProperty *self, PyObject *value)
  152. {
  153. IDProperty *idprop;
  154. PyObject *pyform;
  155. - const char *name = _PyUnicode_AsString(value);
  156. + const char *name = PyUnicode_AsUTF8(value);
  157. if (!name) {
  158. PyErr_Format(PyExc_TypeError,
  159. @@ -1027,7 +1027,7 @@ static PyObject *BPy_IDGroup_items(BPy_IDProperty *self)
  160. static int BPy_IDGroup_Contains(BPy_IDProperty *self, PyObject *value)
  161. {
  162. - const char *name = _PyUnicode_AsString(value);
  163. + const char *name = PyUnicode_AsUTF8(value);
  164. if (!name) {
  165. PyErr_Format(PyExc_TypeError,
  166. @@ -1826,7 +1826,7 @@ void IDP_spit(IDProperty *prop)
  167. ret_str = PyObject_Repr(ret_dict);
  168. Py_DECREF(ret_dict);
  169. - printf("IDProperty(%p): %s\n", prop, _PyUnicode_AsString(ret_str));
  170. + printf("IDProperty(%p): %s\n", prop, PyUnicode_AsUTF8(ret_str));
  171. Py_DECREF(ret_str);
  172. diff --git a/blender-2.79b/source/blender/python/generic/py_capi_utils.c b/blender-2.79b/source/blender/python/generic/py_capi_utils.c
  173. index f4a2595..17cb657 100644
  174. --- a/blender-2.79b/source/blender/python/generic/py_capi_utils.c
  175. +++ b/blender-2.79b/source/blender/python/generic/py_capi_utils.c
  176. @@ -292,7 +292,7 @@ void PyC_FileAndNum(const char **filename, int *lineno)
  177. /* when executing a script */
  178. if (filename) {
  179. - *filename = _PyUnicode_AsString(frame->f_code->co_filename);
  180. + *filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
  181. }
  182. /* when executing a module */
  183. @@ -305,7 +305,7 @@ void PyC_FileAndNum(const char **filename, int *lineno)
  184. if (mod) {
  185. PyObject *mod_file = PyModule_GetFilenameObject(mod);
  186. if (mod_file) {
  187. - *filename = _PyUnicode_AsString(mod_name);
  188. + *filename = PyUnicode_AsUTF8(mod_name);
  189. Py_DECREF(mod_file);
  190. }
  191. else {
  192. @@ -315,7 +315,7 @@ void PyC_FileAndNum(const char **filename, int *lineno)
  193. /* unlikely, fallback */
  194. if (*filename == NULL) {
  195. - *filename = _PyUnicode_AsString(mod_name);
  196. + *filename = PyUnicode_AsUTF8(mod_name);
  197. }
  198. }
  199. }
  200. @@ -554,7 +554,7 @@ const char *PyC_UnicodeAsByteAndSize(PyObject *py_str, Py_ssize_t *size, PyObjec
  201. {
  202. const char *result;
  203. - result = _PyUnicode_AsStringAndSize(py_str, size);
  204. + result = PyUnicode_AsUTF8AndSize(py_str, size);
  205. if (result) {
  206. /* 99% of the time this is enough but we better support non unicode
  207. @@ -583,7 +583,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
  208. {
  209. const char *result;
  210. - result = _PyUnicode_AsString(py_str);
  211. + result = PyUnicode_AsUTF8(py_str);
  212. if (result) {
  213. /* 99% of the time this is enough but we better support non unicode
  214. @@ -975,7 +975,7 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, co
  215. *r_value = 0;
  216. while (_PySet_NextEntry(value, &pos, &key, &hash)) {
  217. - const char *param = _PyUnicode_AsString(key);
  218. + const char *param = PyUnicode_AsUTF8(key);
  219. if (param == NULL) {
  220. PyErr_Format(PyExc_TypeError,
  221. @@ -1100,7 +1100,7 @@ bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_val
  222. const char *val;
  223. Py_ssize_t val_len;
  224. - val = _PyUnicode_AsStringAndSize(retval, &val_len);
  225. + val = PyUnicode_AsUTF8AndSize(retval, &val_len);
  226. if (val == NULL && PyErr_Occurred()) {
  227. ok = false;
  228. }
  229. diff --git a/blender-2.79b/source/blender/python/intern/bpy.c b/blender-2.79b/source/blender/python/intern/bpy.c
  230. index 5bbfb49..a8e2187 100644
  231. --- a/blender-2.79b/source/blender/python/intern/bpy.c
  232. +++ b/blender-2.79b/source/blender/python/intern/bpy.c
  233. @@ -232,7 +232,7 @@ static PyObject *bpy_escape_identifier(PyObject *UNUSED(self), PyObject *value)
  234. PyObject *value_escape;
  235. size_t size;
  236. - value_str = _PyUnicode_AsStringAndSize(value, &value_str_len);
  237. + value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len);
  238. if (value_str == NULL) {
  239. PyErr_SetString(PyExc_TypeError, "expected a string");
  240. diff --git a/blender-2.79b/source/blender/python/intern/bpy_app_translations.c b/blender-2.79b/source/blender/python/intern/bpy_app_translations.c
  241. index 1b853be..6f1e67b 100644
  242. --- a/blender-2.79b/source/blender/python/intern/bpy_app_translations.c
  243. +++ b/blender-2.79b/source/blender/python/intern/bpy_app_translations.c
  244. @@ -193,7 +193,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
  245. msgctxt = BLT_I18NCONTEXT_DEFAULT_BPYRNA;
  246. }
  247. else if (PyUnicode_Check(tmp)) {
  248. - msgctxt = _PyUnicode_AsString(tmp);
  249. + msgctxt = PyUnicode_AsUTF8(tmp);
  250. }
  251. else {
  252. invalid_key = true;
  253. @@ -201,7 +201,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
  254. tmp = PyTuple_GET_ITEM(pykey, 1);
  255. if (PyUnicode_Check(tmp)) {
  256. - msgid = _PyUnicode_AsString(tmp);
  257. + msgid = PyUnicode_AsUTF8(tmp);
  258. }
  259. else {
  260. invalid_key = true;
  261. @@ -231,7 +231,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
  262. /* Do not overwrite existing keys! */
  263. if (BPY_app_translations_py_pgettext(msgctxt, msgid) == msgid) {
  264. GHashKey *key = _ghashutil_keyalloc(msgctxt, msgid);
  265. - BLI_ghash_insert(_translations_cache, key, BLI_strdup(_PyUnicode_AsString(trans)));
  266. + BLI_ghash_insert(_translations_cache, key, BLI_strdup(PyUnicode_AsUTF8(trans)));
  267. }
  268. }
  269. }
  270. @@ -313,7 +313,7 @@ static PyObject *app_translations_py_messages_register(BlenderAppTranslations *s
  271. if (PyDict_Contains(self->py_messages, module_name)) {
  272. PyErr_Format(PyExc_ValueError,
  273. "bpy.app.translations.register: translations message cache already contains some data for "
  274. - "addon '%s'", (const char *)_PyUnicode_AsString(module_name));
  275. + "addon '%s'", (const char *)PyUnicode_AsUTF8(module_name));
  276. return NULL;
  277. }
  278. diff --git a/blender-2.79b/source/blender/python/intern/bpy_interface.c b/blender-2.79b/source/blender/python/intern/bpy_interface.c
  279. index 0d36ba1..5653ba4 100644
  280. --- a/blender-2.79b/source/blender/python/intern/bpy_interface.c
  281. +++ b/blender-2.79b/source/blender/python/intern/bpy_interface.c
  282. @@ -863,7 +863,7 @@ static void bpy_module_delay_init(PyObject *bpy_proxy)
  283. /* updating the module dict below will loose the reference to __file__ */
  284. PyObject *filename_obj = PyModule_GetFilenameObject(bpy_proxy);
  285. - const char *filename_rel = _PyUnicode_AsString(filename_obj); /* can be relative */
  286. + const char *filename_rel = PyUnicode_AsUTF8(filename_obj); /* can be relative */
  287. char filename_abs[1024];
  288. BLI_strncpy(filename_abs, filename_rel, sizeof(filename_abs));
  289. diff --git a/blender-2.79b/source/blender/python/intern/bpy_library_load.c b/blender-2.79b/source/blender/python/intern/bpy_library_load.c
  290. index c8fd392..6ae5318 100644
  291. --- a/blender-2.79b/source/blender/python/intern/bpy_library_load.c
  292. +++ b/blender-2.79b/source/blender/python/intern/bpy_library_load.c
  293. @@ -353,7 +353,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
  294. for (i = 0; i < size; i++) {
  295. PyObject *item_src = PyList_GET_ITEM(ls, i);
  296. PyObject *item_dst; /* must be set below */
  297. - const char *item_idname = _PyUnicode_AsString(item_src);
  298. + const char *item_idname = PyUnicode_AsUTF8(item_src);
  299. // printf(" %s\n", item_idname);
  300. diff --git a/blender-2.79b/source/blender/python/intern/bpy_operator.c b/blender-2.79b/source/blender/python/intern/bpy_operator.c
  301. index c1fcb07..ad6f6cb 100644
  302. --- a/blender-2.79b/source/blender/python/intern/bpy_operator.c
  303. +++ b/blender-2.79b/source/blender/python/intern/bpy_operator.c
  304. @@ -398,7 +398,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
  305. {
  306. wmOperatorType *ot;
  307. PointerRNA ptr;
  308. - const char *opname = _PyUnicode_AsString(value);
  309. + const char *opname = PyUnicode_AsUTF8(value);
  310. BPy_StructRNA *pyrna = NULL;
  311. if (opname == NULL) {
  312. @@ -431,7 +431,7 @@ static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
  313. wmOperatorType *ot;
  314. wmOperator *op;
  315. PointerRNA ptr;
  316. - const char *opname = _PyUnicode_AsString(value);
  317. + const char *opname = PyUnicode_AsUTF8(value);
  318. BPy_StructRNA *pyrna = NULL;
  319. if (opname == NULL) {
  320. diff --git a/blender-2.79b/source/blender/python/intern/bpy_operator_wrap.c b/blender-2.79b/source/blender/python/intern/bpy_operator_wrap.c
  321. index 9071990..5d7e56b 100644
  322. --- a/blender-2.79b/source/blender/python/intern/bpy_operator_wrap.c
  323. +++ b/blender-2.79b/source/blender/python/intern/bpy_operator_wrap.c
  324. @@ -70,7 +70,7 @@ static void operator_properties_init(wmOperatorType *ot)
  325. if (bl_property) {
  326. if (PyUnicode_Check(bl_property)) {
  327. /* since the property is explicitly given, raise an error if its not found */
  328. - prop_id = _PyUnicode_AsString(bl_property);
  329. + prop_id = PyUnicode_AsUTF8(bl_property);
  330. prop_raise_error = true;
  331. }
  332. else {
  333. diff --git a/blender-2.79b/source/blender/python/intern/bpy_props.c b/blender-2.79b/source/blender/python/intern/bpy_props.c
  334. index 2b8e356..aab4276 100644
  335. --- a/blender-2.79b/source/blender/python/intern/bpy_props.c
  336. +++ b/blender-2.79b/source/blender/python/intern/bpy_props.c
  337. @@ -192,9 +192,9 @@ static void printf_func_error(PyObject *py_func)
  338. /* use py style error */
  339. fprintf(stderr, "File \"%s\", line %d, in %s\n",
  340. - _PyUnicode_AsString(f_code->co_filename),
  341. + PyUnicode_AsUTF8(f_code->co_filename),
  342. f_code->co_firstlineno,
  343. - _PyUnicode_AsString(((PyFunctionObject *)py_func)->func_name)
  344. + PyUnicode_AsUTF8(((PyFunctionObject *)py_func)->func_name)
  345. );
  346. }
  347. @@ -1074,7 +1074,7 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
  348. }
  349. else {
  350. Py_ssize_t length;
  351. - const char *buffer = _PyUnicode_AsStringAndSize(ret, &length);
  352. + const char *buffer = PyUnicode_AsUTF8AndSize(ret, &length);
  353. memcpy(value, buffer, length + 1);
  354. Py_DECREF(ret);
  355. }
  356. @@ -1134,7 +1134,7 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
  357. }
  358. else {
  359. Py_ssize_t length_ssize_t = 0;
  360. - _PyUnicode_AsStringAndSize(ret, &length_ssize_t);
  361. + PyUnicode_AsUTF8AndSize(ret, &length_ssize_t);
  362. length = length_ssize_t;
  363. Py_DECREF(ret);
  364. }
  365. @@ -1392,7 +1392,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
  366. }
  367. else {
  368. if (def) {
  369. - def_cmp = _PyUnicode_AsString(def);
  370. + def_cmp = PyUnicode_AsUTF8(def);
  371. if (def_cmp == NULL) {
  372. PyErr_Format(PyExc_TypeError,
  373. "EnumProperty(...): default option must be a 'str' "
  374. @@ -1421,13 +1421,13 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
  375. if ((PyTuple_CheckExact(item)) &&
  376. (item_size = PyTuple_GET_SIZE(item)) &&
  377. (item_size >= 3 && item_size <= 5) &&
  378. - (tmp.identifier = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
  379. - (tmp.name = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 1), &name_str_size)) &&
  380. - (tmp.description = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
  381. + (tmp.identifier = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
  382. + (tmp.name = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 1), &name_str_size)) &&
  383. + (tmp.description = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
  384. /* TODO, number isn't ensured to be unique from the script author */
  385. (item_size != 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1) &&
  386. (item_size != 5 || ((py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.icon) != -1 ||
  387. - (tmp_icon = _PyUnicode_AsString(PyTuple_GET_ITEM(item, 3)))) &&
  388. + (tmp_icon = PyUnicode_AsUTF8(PyTuple_GET_ITEM(item, 3)))) &&
  389. py_long_as_int(PyTuple_GET_ITEM(item, 4), &tmp.value) != -1)))
  390. {
  391. if (is_enum_flag) {
  392. @@ -2845,7 +2845,7 @@ StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix)
  393. if (!srna) {
  394. if (PyErr_Occurred()) {
  395. PyObject *msg = PyC_ExceptionBuffer();
  396. - const char *msg_char = _PyUnicode_AsString(msg);
  397. + const char *msg_char = PyUnicode_AsUTF8(msg);
  398. PyErr_Format(PyExc_TypeError,
  399. "%.200s expected an RNA type, failed with: %s",
  400. error_prefix, msg_char);
  401. diff --git a/blender-2.79b/source/blender/python/intern/bpy_rna.c b/blender-2.79b/source/blender/python/intern/bpy_rna.c
  402. index 26a4351..722e23d 100644
  403. --- a/blender-2.79b/source/blender/python/intern/bpy_rna.c
  404. +++ b/blender-2.79b/source/blender/python/intern/bpy_rna.c
  405. @@ -313,7 +313,7 @@ static bool rna_id_write_error(PointerRNA *ptr, PyObject *key)
  406. if (!ELEM(idcode, ID_WM, ID_SCR)) { /* may need more added here */
  407. const char *idtype = BKE_idcode_to_name(idcode);
  408. const char *pyname;
  409. - if (key && PyUnicode_Check(key)) pyname = _PyUnicode_AsString(key);
  410. + if (key && PyUnicode_Check(key)) pyname = PyUnicode_AsUTF8(key);
  411. else pyname = "<UNKNOWN>";
  412. /* make a nice string error */
  413. @@ -1188,7 +1188,7 @@ static int pyrna_string_to_enum(
  414. PyObject *item, PointerRNA *ptr, PropertyRNA *prop, int *r_value,
  415. const char *error_prefix)
  416. {
  417. - const char *param = _PyUnicode_AsString(item);
  418. + const char *param = PyUnicode_AsUTF8(item);
  419. if (param == NULL) {
  420. PyErr_Format(PyExc_TypeError,
  421. @@ -1232,7 +1232,7 @@ BLI_bitmap *pyrna_set_to_enum_bitmap(
  422. BLI_bitmap *bitmap = BLI_BITMAP_NEW(bitmap_size, __func__);
  423. while (_PySet_NextEntry(value, &pos, &key, &hash)) {
  424. - const char *param = _PyUnicode_AsString(key);
  425. + const char *param = PyUnicode_AsUTF8(key);
  426. if (param == NULL) {
  427. PyErr_Format(PyExc_TypeError,
  428. "%.200s expected a string, not %.200s",
  429. @@ -1289,7 +1289,7 @@ int pyrna_set_to_enum_bitfield(
  430. *r_value = 0;
  431. while (_PySet_NextEntry(value, &pos, &key, &hash)) {
  432. - const char *param = _PyUnicode_AsString(key);
  433. + const char *param = PyUnicode_AsUTF8(key);
  434. if (param == NULL) {
  435. PyErr_Format(PyExc_TypeError,
  436. @@ -1590,7 +1590,7 @@ int pyrna_pydict_to_props(
  437. Py_ssize_t pos = 0;
  438. while (PyDict_Next(kw, &pos, &key, &value)) {
  439. - arg_name = _PyUnicode_AsString(key);
  440. + arg_name = PyUnicode_AsUTF8(key);
  441. if (RNA_struct_find_property(ptr, arg_name) == NULL) break;
  442. arg_name = NULL;
  443. }
  444. @@ -1761,10 +1761,10 @@ static int pyrna_py_to_prop(
  445. param = PyC_UnicodeAsByte(value, &value_coerce);
  446. }
  447. else {
  448. - param = _PyUnicode_AsString(value);
  449. + param = PyUnicode_AsUTF8(value);
  450. }
  451. #else /* USE_STRING_COERCE */
  452. - param = _PyUnicode_AsString(value);
  453. + param = PyUnicode_AsUTF8(value);
  454. #endif /* USE_STRING_COERCE */
  455. if (param == NULL) {
  456. @@ -2019,7 +2019,7 @@ static int pyrna_py_to_prop(
  457. "Converting a python list to an RNA collection") == -1)
  458. {
  459. PyObject *msg = PyC_ExceptionBuffer();
  460. - const char *msg_char = _PyUnicode_AsString(msg);
  461. + const char *msg_char = PyUnicode_AsUTF8(msg);
  462. PyErr_Format(PyExc_TypeError,
  463. "%.200s %.200s.%.200s error converting a member of a collection "
  464. @@ -2310,7 +2310,7 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(
  465. err_prefix, RNA_struct_identifier(self->ptr.type));
  466. return -1;
  467. }
  468. - else if ((keyname = _PyUnicode_AsString(PyTuple_GET_ITEM(key, 0))) == NULL) {
  469. + else if ((keyname = PyUnicode_AsUTF8(PyTuple_GET_ITEM(key, 0))) == NULL) {
  470. PyErr_Format(PyExc_KeyError,
  471. "%s: id must be a string, not %.200s",
  472. err_prefix, Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
  473. @@ -2326,7 +2326,7 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(
  474. }
  475. else if (PyUnicode_Check(keylib)) {
  476. Main *bmain = self->ptr.data;
  477. - const char *keylib_str = _PyUnicode_AsString(keylib);
  478. + const char *keylib_str = PyUnicode_AsUTF8(keylib);
  479. lib = BLI_findstring(&bmain->library, keylib_str, offsetof(Library, name));
  480. if (lib == NULL) {
  481. if (err_not_found) {
  482. @@ -2517,7 +2517,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
  483. PYRNA_PROP_CHECK_OBJ(self);
  484. if (PyUnicode_Check(key)) {
  485. - return pyrna_prop_collection_subscript_str(self, _PyUnicode_AsString(key));
  486. + return pyrna_prop_collection_subscript_str(self, PyUnicode_AsUTF8(key));
  487. }
  488. else if (PyIndex_Check(key)) {
  489. Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
  490. @@ -2640,7 +2640,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, PyObject *
  491. #if 0
  492. if (PyUnicode_Check(key)) {
  493. - return pyrna_prop_collection_subscript_str(self, _PyUnicode_AsString(key));
  494. + return pyrna_prop_collection_subscript_str(self, PyUnicode_AsUTF8(key));
  495. }
  496. else
  497. #endif
  498. @@ -2704,7 +2704,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
  499. #if 0
  500. if (PyUnicode_Check(key)) {
  501. - return pyrna_prop_array_subscript_str(self, _PyUnicode_AsString(key));
  502. + return pyrna_prop_array_subscript_str(self, PyUnicode_AsUTF8(key));
  503. }
  504. else
  505. #endif
  506. @@ -3141,7 +3141,7 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
  507. else {
  508. /* key in dict style check */
  509. - const char *keyname = _PyUnicode_AsString(key);
  510. + const char *keyname = PyUnicode_AsUTF8(key);
  511. if (keyname == NULL) {
  512. PyErr_SetString(PyExc_TypeError,
  513. @@ -3159,7 +3159,7 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
  514. static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
  515. {
  516. IDProperty *group;
  517. - const char *name = _PyUnicode_AsString(value);
  518. + const char *name = PyUnicode_AsUTF8(value);
  519. PYRNA_STRUCT_CHECK_INT(self);
  520. @@ -3224,7 +3224,7 @@ static PyObject *pyrna_struct_subscript(BPy_StructRNA *self, PyObject *key)
  521. {
  522. /* mostly copied from BPy_IDGroup_Map_GetItem */
  523. IDProperty *group, *idprop;
  524. - const char *name = _PyUnicode_AsString(key);
  525. + const char *name = PyUnicode_AsUTF8(key);
  526. PYRNA_STRUCT_CHECK_OBJ(self);
  527. @@ -3841,7 +3841,7 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
  528. /* ---------------getattr-------------------------------------------- */
  529. static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
  530. {
  531. - const char *name = _PyUnicode_AsString(pyname);
  532. + const char *name = PyUnicode_AsUTF8(pyname);
  533. PyObject *ret;
  534. PropertyRNA *prop;
  535. FunctionRNA *func;
  536. @@ -3985,7 +3985,7 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
  537. if (ret == NULL) { // || pyrna_is_deferred_prop(ret)
  538. StructRNA *srna = srna_from_self(cls, "StructRNA.__getattr__");
  539. if (srna) {
  540. - PropertyRNA *prop = RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr));
  541. + PropertyRNA *prop = RNA_struct_type_find_property(srna, PyUnicode_AsUTF8(attr));
  542. if (prop) {
  543. PointerRNA tptr;
  544. PyErr_Clear(); /* clear error from tp_getattro */
  545. @@ -4004,7 +4004,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
  546. {
  547. StructRNA *srna = srna_from_self(cls, "StructRNA.__setattr__");
  548. const bool is_deferred_prop = (value && pyrna_is_deferred_prop(value));
  549. - const char *attr_str = _PyUnicode_AsString(attr);
  550. + const char *attr_str = PyUnicode_AsUTF8(attr);
  551. if (srna && !pyrna_write_check() && (is_deferred_prop || RNA_struct_type_find_property(srna, attr_str))) {
  552. PyErr_Format(PyExc_AttributeError,
  553. @@ -4064,7 +4064,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
  554. static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject *value)
  555. {
  556. - const char *name = _PyUnicode_AsString(pyname);
  557. + const char *name = PyUnicode_AsUTF8(pyname);
  558. PropertyRNA *prop = NULL;
  559. PYRNA_STRUCT_CHECK_INT(self);
  560. @@ -4159,7 +4159,7 @@ static PyObject *pyrna_prop_array_getattro(BPy_PropertyRNA *self, PyObject *pyna
  561. static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject *pyname)
  562. {
  563. - const char *name = _PyUnicode_AsString(pyname);
  564. + const char *name = PyUnicode_AsUTF8(pyname);
  565. if (name == NULL) {
  566. PyErr_SetString(PyExc_AttributeError, "bpy_prop_collection: __getattr__ must be a string");
  567. @@ -4227,7 +4227,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
  568. /* --------------- setattr------------------------------------------- */
  569. static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pyname, PyObject *value)
  570. {
  571. - const char *name = _PyUnicode_AsString(pyname);
  572. + const char *name = PyUnicode_AsUTF8(pyname);
  573. PropertyRNA *prop;
  574. PointerRNA r_ptr;
  575. @@ -4573,7 +4573,7 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args
  576. return NULL;
  577. if (PyUnicode_Check(key_ob)) {
  578. - const char *key = _PyUnicode_AsString(key_ob);
  579. + const char *key = PyUnicode_AsUTF8(key_ob);
  580. if (RNA_property_collection_lookup_string(&self->ptr, self->prop, key, &newptr))
  581. return pyrna_struct_CreatePyObject(&newptr);
  582. @@ -4608,7 +4608,7 @@ PyDoc_STRVAR(pyrna_prop_collection_find_doc,
  583. static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key_ob)
  584. {
  585. Py_ssize_t key_len_ssize_t;
  586. - const char *key = _PyUnicode_AsStringAndSize(key_ob, &key_len_ssize_t);
  587. + const char *key = PyUnicode_AsUTF8AndSize(key_ob, &key_len_ssize_t);
  588. const int key_len = (int)key_len_ssize_t; /* comare with same type */
  589. char name[256], *nameptr;
  590. @@ -5308,7 +5308,7 @@ static PyObject *small_dict_get_item_string(PyObject *dict, const char *key_look
  591. while (PyDict_Next(dict, &pos, &key, &value)) {
  592. if (PyUnicode_Check(key)) {
  593. - if (STREQ(key_lookup, _PyUnicode_AsString(key))) {
  594. + if (STREQ(key_lookup, PyUnicode_AsUTF8(key))) {
  595. return value;
  596. }
  597. }
  598. @@ -5444,7 +5444,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
  599. #ifdef DEBUG_STRING_FREE
  600. if (item) {
  601. if (PyUnicode_Check(item)) {
  602. - PyList_APPEND(string_free_ls, PyUnicode_FromString(_PyUnicode_AsString(item)));
  603. + PyList_APPEND(string_free_ls, PyUnicode_FromString(PyUnicode_AsUTF8(item)));
  604. }
  605. }
  606. #endif
  607. @@ -5495,7 +5495,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
  608. while (PyDict_Next(kw, &pos, &key, &value)) {
  609. - arg_name = _PyUnicode_AsString(key);
  610. + arg_name = PyUnicode_AsUTF8(key);
  611. found = false;
  612. if (arg_name == NULL) { /* unlikely the argname is not a string but ignore if it is*/
  613. @@ -6862,7 +6862,7 @@ static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname
  614. {
  615. PointerRNA newptr;
  616. PyObject *ret;
  617. - const char *name = _PyUnicode_AsString(pyname);
  618. + const char *name = PyUnicode_AsUTF8(pyname);
  619. if (name == NULL) {
  620. PyErr_SetString(PyExc_AttributeError, "bpy.types: __getattr__ must be a string");
  621. @@ -6873,14 +6873,14 @@ static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname
  622. if (ret == NULL) {
  623. PyErr_Format(PyExc_RuntimeError,
  624. "bpy.types.%.200s subtype could not be generated, this is a bug!",
  625. - _PyUnicode_AsString(pyname));
  626. + PyUnicode_AsUTF8(pyname));
  627. }
  628. }
  629. else {
  630. #if 0
  631. PyErr_Format(PyExc_AttributeError,
  632. "bpy.types.%.200s RNA_Struct does not exist",
  633. - _PyUnicode_AsString(pyname));
  634. + PyUnicode_AsUTF8(pyname));
  635. return NULL;
  636. #endif
  637. /* The error raised here will be displayed */
  638. @@ -7090,11 +7090,11 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
  639. if (PyArg_ParseTuple(item, "OO!", &py_func, &PyDict_Type, &py_kw)) {
  640. PyObject *args_fake;
  641. - if (*_PyUnicode_AsString(key) == '_') {
  642. + if (*PyUnicode_AsUTF8(key) == '_') {
  643. PyErr_Format(PyExc_ValueError,
  644. "bpy_struct \"%.200s\" registration error: "
  645. "%.200s could not register because the property starts with an '_'\n",
  646. - RNA_struct_identifier(srna), _PyUnicode_AsString(key));
  647. + RNA_struct_identifier(srna), PyUnicode_AsUTF8(key));
  648. return -1;
  649. }
  650. py_srna_cobject = PyCapsule_New(srna, NULL, NULL);
  651. @@ -7137,7 +7137,7 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
  652. PyErr_Format(PyExc_ValueError,
  653. "bpy_struct \"%.200s\" registration error: "
  654. "%.200s could not register\n",
  655. - RNA_struct_identifier(srna), _PyUnicode_AsString(key));
  656. + RNA_struct_identifier(srna), PyUnicode_AsUTF8(key));
  657. return -1;
  658. }
  659. }
  660. diff --git a/blender-2.79b/source/blender/python/intern/bpy_traceback.c b/blender-2.79b/source/blender/python/intern/bpy_traceback.c
  661. index bff778b..fedf889 100644
  662. --- a/blender-2.79b/source/blender/python/intern/bpy_traceback.c
  663. +++ b/blender-2.79b/source/blender/python/intern/bpy_traceback.c
  664. @@ -143,7 +143,7 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
  665. PyObject *filename_py, *text_py;
  666. if (parse_syntax_error(value, &message, &filename_py, lineno, offset, &text_py)) {
  667. - const char *filename = _PyUnicode_AsString(filename_py);
  668. + const char *filename = PyUnicode_AsUTF8(filename_py);
  669. /* python adds a '/', prefix, so check for both */
  670. if ((BLI_path_cmp(filename, filepath) == 0) ||
  671. ((filename[0] == '\\' || filename[0] == '/') && BLI_path_cmp(filename + 1, filepath) == 0))
  672. diff --git a/blender-2.79b/source/blender/python/intern/bpy_util.c b/blender-2.79b/source/blender/python/intern/bpy_util.c
  673. index 2b8ad6c..a292147 100644
  674. --- a/blender-2.79b/source/blender/python/intern/bpy_util.c
  675. +++ b/blender-2.79b/source/blender/python/intern/bpy_util.c
  676. @@ -121,13 +121,13 @@ bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const boo
  677. }
  678. #if 0 /* ARG!. workaround for a bug in blenders use of vsnprintf */
  679. - BKE_reportf(reports, RPT_ERROR, "%s\nlocation: %s:%d\n", _PyUnicode_AsString(pystring), filename, lineno);
  680. + BKE_reportf(reports, RPT_ERROR, "%s\nlocation: %s:%d\n", PyUnicode_AsUTF8(pystring), filename, lineno);
  681. #else
  682. pystring_format = PyUnicode_FromFormat(
  683. TIP_("%s\nlocation: %s:%d\n"),
  684. - _PyUnicode_AsString(pystring), filename, lineno);
  685. + PyUnicode_AsUTF8(pystring), filename, lineno);
  686. - cstring = _PyUnicode_AsString(pystring_format);
  687. + cstring = PyUnicode_AsUTF8(pystring_format);
  688. BKE_report(reports, RPT_ERROR, cstring);
  689. /* not exactly needed. just for testing */
  690. @@ -137,7 +137,7 @@ bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const boo
  691. #endif
  692. }
  693. else {
  694. - BKE_report(reports, RPT_ERROR, _PyUnicode_AsString(pystring));
  695. + BKE_report(reports, RPT_ERROR, PyUnicode_AsUTF8(pystring));
  696. }
  697. diff --git a/blender-2.79b/source/blender/python/mathutils/mathutils.c b/blender-2.79b/source/blender/python/mathutils/mathutils.c
  698. index 21d3624..8b0959e 100644
  699. --- a/blender-2.79b/source/blender/python/mathutils/mathutils.c
  700. +++ b/blender-2.79b/source/blender/python/mathutils/mathutils.c
  701. @@ -110,7 +110,11 @@ Py_hash_t mathutils_array_hash(const float *array, size_t array_len)
  702. x = 0x345678UL;
  703. i = 0;
  704. while (--len >= 0) {
  705. +#if PY_VERSION_HEX >= 0x30a0000 /* Version: 3.10. */
  706. + y = _Py_HashDouble(NULL, (double)(array[i++]));
  707. +#else
  708. y = _Py_HashDouble((double)(array[i++]));
  709. +#endif
  710. if (y == -1)
  711. return -1;
  712. x = (x ^ y) * mult;
  713. diff --git a/blender-2.79b/source/blender/python/mathutils/mathutils_Euler.c b/blender-2.79b/source/blender/python/mathutils/mathutils_Euler.c
  714. index 494b5ea..d4200fb 100644
  715. --- a/blender-2.79b/source/blender/python/mathutils/mathutils_Euler.c
  716. +++ b/blender-2.79b/source/blender/python/mathutils/mathutils_Euler.c
  717. @@ -639,7 +639,7 @@ static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(clos
  718. if (BaseMath_Prepare_ForWrite(self) == -1)
  719. return -1;
  720. - if (((order_str = _PyUnicode_AsString(value)) == NULL) ||
  721. + if (((order_str = PyUnicode_AsUTF8(value)) == NULL) ||
  722. ((order = euler_order_from_string(order_str, "euler.order")) == -1))
  723. {
  724. return -1;
  725. diff --git a/blender-2.79b/source/blender/python/mathutils/mathutils_Matrix.c b/blender-2.79b/source/blender/python/mathutils/mathutils_Matrix.c
  726. index 0805ab1..d535e17 100644
  727. --- a/blender-2.79b/source/blender/python/mathutils/mathutils_Matrix.c
  728. +++ b/blender-2.79b/source/blender/python/mathutils/mathutils_Matrix.c
  729. @@ -482,7 +482,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
  730. }
  731. if (vec && PyUnicode_Check(vec)) {
  732. - axis = _PyUnicode_AsString((PyObject *)vec);
  733. + axis = PyUnicode_AsUTF8((PyObject *)vec);
  734. if (axis == NULL || axis[0] == '\0' || axis[1] != '\0' || axis[0] < 'X' || axis[0] > 'Z') {
  735. PyErr_SetString(PyExc_ValueError,
  736. "Matrix.Rotation(): "
  737. @@ -695,7 +695,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
  738. if (PyUnicode_Check(axis)) { /* ortho projection onto cardinal plane */
  739. Py_ssize_t plane_len;
  740. - const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len);
  741. + const char *plane = PyUnicode_AsUTF8AndSize(axis, &plane_len);
  742. if (matSize == 2) {
  743. if (plane_len == 1 && plane[0] == 'X') {
  744. mat[0] = 1.0f;
  745. diff --git a/blender-2.79b/source/gameengine/Converter/BL_ActionActuator.cpp b/blender-2.79b/source/gameengine/Converter/BL_ActionActuator.cpp
  746. index d28cdb8..abbcd38 100644
  747. --- a/blender-2.79b/source/gameengine/Converter/BL_ActionActuator.cpp
  748. +++ b/blender-2.79b/source/gameengine/Converter/BL_ActionActuator.cpp
  749. @@ -358,7 +358,7 @@ PyObject *BL_ActionActuator::PyGetChannel(PyObject *value)
  750. PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.getChannel() no longer works, please use BL_ArmatureObject.channels instead");
  751. return NULL;
  752. #if 0 // XXX To be removed in a later version (first removed in 2.64)
  753. - const char *string= _PyUnicode_AsString(value);
  754. + const char *string= PyUnicode_AsUTF8(value);
  755. if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
  756. {
  757. @@ -580,7 +580,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF
  758. }
  759. bAction *action= NULL;
  760. - STR_String val = _PyUnicode_AsString(value);
  761. + STR_String val = PyUnicode_AsUTF8(value);
  762. if (val != "")
  763. {
  764. diff --git a/blender-2.79b/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/blender-2.79b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
  765. index f21db41..dcb6433 100644
  766. --- a/blender-2.79b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
  767. +++ b/blender-2.79b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
  768. @@ -543,7 +543,7 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE
  769. }
  770. bAction *action= NULL;
  771. - STR_String val = _PyUnicode_AsString(value);
  772. + STR_String val = PyUnicode_AsUTF8(value);
  773. if (val != "")
  774. {
  775. diff --git a/blender-2.79b/source/gameengine/Expressions/intern/ListValue.cpp b/blender-2.79b/source/gameengine/Expressions/intern/ListValue.cpp
  776. index 557ce7b..7111fc8 100644
  777. --- a/blender-2.79b/source/gameengine/Expressions/intern/ListValue.cpp
  778. +++ b/blender-2.79b/source/gameengine/Expressions/intern/ListValue.cpp
  779. @@ -362,7 +362,7 @@ static PyObject *listvalue_mapping_subscript(PyObject *self, PyObject *key)
  780. }
  781. if (PyUnicode_Check(key)) {
  782. - CValue *item = ((CListValue*) list)->FindValue(_PyUnicode_AsString(key));
  783. + CValue *item = ((CListValue*) list)->FindValue(PyUnicode_AsUTF8(key));
  784. if (item) {
  785. PyObject *pyobj = item->ConvertValueToPython();
  786. if (pyobj)
  787. @@ -483,7 +483,7 @@ static int listvalue_buffer_contains(PyObject *self_v, PyObject *value)
  788. }
  789. if (PyUnicode_Check(value)) {
  790. - if (self->FindValue((const char *)_PyUnicode_AsString(value))) {
  791. + if (self->FindValue((const char *)PyUnicode_AsUTF8(value))) {
  792. return 1;
  793. }
  794. }
  795. diff --git a/blender-2.79b/source/gameengine/Expressions/intern/ListWrapper.cpp b/blender-2.79b/source/gameengine/Expressions/intern/ListWrapper.cpp
  796. index db1518a..92737cf 100644
  797. --- a/blender-2.79b/source/gameengine/Expressions/intern/ListWrapper.cpp
  798. +++ b/blender-2.79b/source/gameengine/Expressions/intern/ListWrapper.cpp
  799. @@ -240,7 +240,7 @@ PyObject *CListWrapper::py_mapping_subscript(PyObject *self, PyObject *key)
  800. return NULL;
  801. }
  802. - const char *name = _PyUnicode_AsString(key);
  803. + const char *name = PyUnicode_AsUTF8(key);
  804. int size = list->GetSize();
  805. for (unsigned int i = 0; i < size; ++i) {
  806. @@ -281,7 +281,7 @@ int CListWrapper::py_mapping_ass_subscript(PyObject *self, PyObject *key, PyObje
  807. return -1;
  808. }
  809. - const char *name = _PyUnicode_AsString(key);
  810. + const char *name = PyUnicode_AsUTF8(key);
  811. int size = list->GetSize();
  812. for (unsigned int i = 0; i < size; ++i) {
  813. @@ -320,7 +320,7 @@ int CListWrapper::py_contains(PyObject *self, PyObject *key)
  814. return -1;
  815. }
  816. - const char *name = _PyUnicode_AsString(key);
  817. + const char *name = PyUnicode_AsUTF8(key);
  818. int size = list->GetSize();
  819. for (unsigned int i = 0; i < size; ++i) {
  820. diff --git a/blender-2.79b/source/gameengine/Expressions/intern/PyObjectPlus.cpp b/blender-2.79b/source/gameengine/Expressions/intern/PyObjectPlus.cpp
  821. index 1e4a59a..8c0f056 100644
  822. --- a/blender-2.79b/source/gameengine/Expressions/intern/PyObjectPlus.cpp
  823. +++ b/blender-2.79b/source/gameengine/Expressions/intern/PyObjectPlus.cpp
  824. @@ -1021,7 +1021,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
  825. if (PyUnicode_Check(value))
  826. {
  827. Py_ssize_t val_size;
  828. - const char *val = _PyUnicode_AsStringAndSize(value, &val_size);
  829. + const char *val = PyUnicode_AsUTF8AndSize(value, &val_size);
  830. strncpy(ptr, val, attrdef->m_size);
  831. ptr[attrdef->m_size-1] = 0;
  832. }
  833. @@ -1038,7 +1038,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
  834. if (PyUnicode_Check(value))
  835. {
  836. Py_ssize_t val_len;
  837. - const char *val = _PyUnicode_AsStringAndSize(value, &val_len); /* XXX, should be 'const' but we do a silly trick to have a shorter string */
  838. + const char *val = PyUnicode_AsUTF8AndSize(value, &val_len); /* XXX, should be 'const' but we do a silly trick to have a shorter string */
  839. if (attrdef->m_clamp)
  840. {
  841. if (val_len < attrdef->m_imin)
  842. diff --git a/blender-2.79b/source/gameengine/Expressions/intern/Value.cpp b/blender-2.79b/source/gameengine/Expressions/intern/Value.cpp
  843. index f8796a7..ecc5142 100644
  844. --- a/blender-2.79b/source/gameengine/Expressions/intern/Value.cpp
  845. +++ b/blender-2.79b/source/gameengine/Expressions/intern/Value.cpp
  846. @@ -612,7 +612,7 @@ CValue *CValue::ConvertPythonToValue(PyObject *pyobj, const bool do_type_excepti
  847. } else
  848. if (PyUnicode_Check(pyobj))
  849. {
  850. - vallie = new CStringValue(_PyUnicode_AsString(pyobj),"");
  851. + vallie = new CStringValue(PyUnicode_AsUTF8(pyobj),"");
  852. } else
  853. if (PyObject_TypeCheck(pyobj, &CValue::Type)) /* Note, don't let these get assigned to GameObject props, must check elsewhere */
  854. {
  855. diff --git a/blender-2.79b/source/gameengine/GameLogic/SCA_PythonController.cpp b/blender-2.79b/source/gameengine/GameLogic/SCA_PythonController.cpp
  856. index fd2e723..6aaf6f0 100644
  857. --- a/blender-2.79b/source/gameengine/GameLogic/SCA_PythonController.cpp
  858. +++ b/blender-2.79b/source/gameengine/GameLogic/SCA_PythonController.cpp
  859. @@ -204,7 +204,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
  860. if (PyUnicode_Check(value)) {
  861. /* get the actuator from the name */
  862. - const char *name= _PyUnicode_AsString(value);
  863. + const char *name= PyUnicode_AsUTF8(value);
  864. for (it = lacts.begin(); it!= lacts.end(); ++it) {
  865. if ( name == (*it)->GetName() ) {
  866. return *it;
  867. @@ -513,7 +513,7 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D
  868. {
  869. SCA_PythonController* self = static_cast<SCA_PythonController*>(self_v);
  870. - const char *scriptArg = _PyUnicode_AsString(value);
  871. + const char *scriptArg = PyUnicode_AsUTF8(value);
  872. if (scriptArg==NULL) {
  873. PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text");
  874. diff --git a/blender-2.79b/source/gameengine/Ketsji/KX_Camera.cpp b/blender-2.79b/source/gameengine/Ketsji/KX_Camera.cpp
  875. index 89aea80..51b2272 100644
  876. --- a/blender-2.79b/source/gameengine/Ketsji/KX_Camera.cpp
  877. +++ b/blender-2.79b/source/gameengine/Ketsji/KX_Camera.cpp
  878. @@ -987,7 +987,7 @@ bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok,
  879. }
  880. if (PyUnicode_Check(value)) {
  881. - STR_String value_str = _PyUnicode_AsString(value);
  882. + STR_String value_str = PyUnicode_AsUTF8(value);
  883. *object = KX_GetActiveScene()->FindCamera(value_str);
  884. if (*object) {
  885. @@ -995,7 +995,7 @@ bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok,
  886. } else {
  887. PyErr_Format(PyExc_ValueError,
  888. "%s, requested name \"%s\" did not match any KX_Camera in this scene",
  889. - error_prefix, _PyUnicode_AsString(value));
  890. + error_prefix, PyUnicode_AsUTF8(value));
  891. return false;
  892. }
  893. }
  894. diff --git a/blender-2.79b/source/gameengine/Ketsji/KX_FontObject.cpp b/blender-2.79b/source/gameengine/Ketsji/KX_FontObject.cpp
  895. index 91e8e4f..62ad415 100644
  896. --- a/blender-2.79b/source/gameengine/Ketsji/KX_FontObject.cpp
  897. +++ b/blender-2.79b/source/gameengine/Ketsji/KX_FontObject.cpp
  898. @@ -281,7 +281,7 @@ int KX_FontObject::pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrd
  899. KX_FontObject* self = static_cast<KX_FontObject*>(self_v);
  900. if (!PyUnicode_Check(value))
  901. return PY_SET_ATTR_FAIL;
  902. - const char *chars = _PyUnicode_AsString(value);
  903. + const char *chars = PyUnicode_AsUTF8(value);
  904. /* Allow for some logic brick control */
  905. CValue* tprop = self->GetProperty("Text");
  906. diff --git a/blender-2.79b/source/gameengine/Ketsji/KX_GameObject.cpp b/blender-2.79b/source/gameengine/Ketsji/KX_GameObject.cpp
  907. index 3244400..e6f8e00 100644
  908. --- a/blender-2.79b/source/gameengine/Ketsji/KX_GameObject.cpp
  909. +++ b/blender-2.79b/source/gameengine/Ketsji/KX_GameObject.cpp
  910. @@ -2087,7 +2087,7 @@ PyObject *KX_GameObject::PyReinstancePhysicsMesh(PyObject *args)
  911. static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
  912. {
  913. KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
  914. - const char *attr_str= _PyUnicode_AsString(item);
  915. + const char *attr_str= PyUnicode_AsUTF8(item);
  916. CValue* resultattr;
  917. PyObject *pyconvert;
  918. @@ -2121,7 +2121,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
  919. static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
  920. {
  921. KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
  922. - const char *attr_str= _PyUnicode_AsString(key);
  923. + const char *attr_str= PyUnicode_AsUTF8(key);
  924. if (attr_str==NULL)
  925. PyErr_Clear();
  926. @@ -2214,7 +2214,7 @@ static int Seq_Contains(PyObject *self_v, PyObject *value)
  927. return -1;
  928. }
  929. - if (PyUnicode_Check(value) && self->GetProperty(_PyUnicode_AsString(value)))
  930. + if (PyUnicode_Check(value) && self->GetProperty(PyUnicode_AsUTF8(value)))
  931. return 1;
  932. if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value))
  933. @@ -4124,7 +4124,7 @@ PyObject *KX_GameObject::Pyget(PyObject *args)
  934. if (PyUnicode_Check(key)) {
  935. - CValue *item = GetProperty(_PyUnicode_AsString(key));
  936. + CValue *item = GetProperty(PyUnicode_AsUTF8(key));
  937. if (item) {
  938. ret = item->ConvertValueToPython();
  939. if (ret)
  940. @@ -4163,12 +4163,12 @@ bool ConvertPythonToGameObject(SCA_LogicManager *manager, PyObject *value, KX_Ga
  941. }
  942. if (PyUnicode_Check(value)) {
  943. - *object = (KX_GameObject*)manager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) ));
  944. + *object = (KX_GameObject*)manager->GetGameObjectByName(STR_String( PyUnicode_AsUTF8(value) ));
  945. if (*object) {
  946. return true;
  947. } else {
  948. - PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_GameObject in this scene", error_prefix, _PyUnicode_AsString(value));
  949. + PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_GameObject in this scene", error_prefix, PyUnicode_AsUTF8(value));
  950. return false;
  951. }
  952. }
  953. diff --git a/blender-2.79b/source/gameengine/Ketsji/KX_MeshProxy.cpp b/blender-2.79b/source/gameengine/Ketsji/KX_MeshProxy.cpp
  954. index 8da3542..0da22dc 100644
  955. --- a/blender-2.79b/source/gameengine/Ketsji/KX_MeshProxy.cpp
  956. +++ b/blender-2.79b/source/gameengine/Ketsji/KX_MeshProxy.cpp
  957. @@ -427,12 +427,12 @@ bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, RAS_MeshOb
  958. }
  959. if (PyUnicode_Check(value)) {
  960. - *object = (RAS_MeshObject*)logicmgr->GetMeshByName(STR_String( _PyUnicode_AsString(value) ));
  961. + *object = (RAS_MeshObject*)logicmgr->GetMeshByName(STR_String( PyUnicode_AsUTF8(value) ));
  962. if (*object) {
  963. return true;
  964. } else {
  965. - PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_MeshProxy in this scene", error_prefix, _PyUnicode_AsString(value));
  966. + PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_MeshProxy in this scene", error_prefix, PyUnicode_AsUTF8(value));
  967. return false;
  968. }
  969. }
  970. diff --git a/blender-2.79b/source/gameengine/Ketsji/KX_PythonInit.cpp b/blender-2.79b/source/gameengine/Ketsji/KX_PythonInit.cpp
  971. index 71e610d..a112a63 100644
  972. --- a/blender-2.79b/source/gameengine/Ketsji/KX_PythonInit.cpp
  973. +++ b/blender-2.79b/source/gameengine/Ketsji/KX_PythonInit.cpp
  974. @@ -825,7 +825,7 @@ static PyObject *gLibNew(PyObject *, PyObject *args)
  975. PyObject *ret= PyList_New(0);
  976. PyObject *item;
  977. for (Py_ssize_t i= 0; i < PyList_GET_SIZE(names); i++) {
  978. - name= _PyUnicode_AsString(PyList_GET_ITEM(names, i));
  979. + name= PyUnicode_AsUTF8(PyList_GET_ITEM(names, i));
  980. if (name) {
  981. RAS_MeshObject *meshobj= kx_scene->GetSceneConverter()->ConvertMeshSpecial(kx_scene, maggie, name);
  982. if (meshobj) {
  983. diff --git a/blender-2.79b/source/gameengine/Ketsji/KX_Scene.cpp b/blender-2.79b/source/gameengine/Ketsji/KX_Scene.cpp
  984. index b306108..86e51f5 100644
  985. --- a/blender-2.79b/source/gameengine/Ketsji/KX_Scene.cpp
  986. +++ b/blender-2.79b/source/gameengine/Ketsji/KX_Scene.cpp
  987. @@ -2218,7 +2218,7 @@ PyMethodDef KX_Scene::Methods[] = {
  988. static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
  989. {
  990. KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v);
  991. - const char *attr_str= _PyUnicode_AsString(item);
  992. + const char *attr_str= PyUnicode_AsUTF8(item);
  993. PyObject *pyconvert;
  994. if (self == NULL) {
  995. @@ -2247,7 +2247,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
  996. static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
  997. {
  998. KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v);
  999. - const char *attr_str= _PyUnicode_AsString(key);
  1000. + const char *attr_str= PyUnicode_AsUTF8(key);
  1001. if (attr_str==NULL)
  1002. PyErr_Clear();