[Bf-blender-cvs] [a0f2866a8e3] master: Cleanup: update old comment for why we can't use PySys_SetArgv

Campbell Barton noreply at git.blender.org
Wed Oct 28 04:05:33 CET 2020


Commit: a0f2866a8e330d7f04dd2f330051b79e3eec98be
Author: Campbell Barton
Date:   Wed Oct 28 13:48:02 2020 +1100
Branches: master
https://developer.blender.org/rBa0f2866a8e330d7f04dd2f330051b79e3eec98be

Cleanup: update old comment for why we can't use PySys_SetArgv

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

M	source/blender/python/intern/bpy_interface.c

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

diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 894a9a69198..e8d309b8a50 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -349,17 +349,16 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
   /* Initialize Python (also acquires lock). */
   Py_Initialize();
 
-  // PySys_SetArgv(argc, argv);  /* broken in py3, not a huge deal */
-  /* sigh, why do python guys not have a (char **) version anymore? */
+  /* We could convert to #wchar_t then pass to #PySys_SetArgv (or use #PyConfig in Python 3.8+).
+   * However this risks introducing subtle changes in encoding that are hard to track down.
+   *
+   * So rely on #PyC_UnicodeFromByte since it's a tried & true way of getting paths
+   * that include non `utf-8` compatible characters, see: T20021. */
   {
-    int i;
     PyObject *py_argv = PyList_New(argc);
-    for (i = 0; i < argc; i++) {
-      /* should fix bug T20021 - utf path name problems, by replacing
-       * PyUnicode_FromString, with this one */
+    for (int i = 0; i < argc; i++) {
       PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i]));
     }
-
     PySys_SetObject("argv", py_argv);
     Py_DECREF(py_argv);
   }



More information about the Bf-blender-cvs mailing list