[#20021] Non-ASCII characters on blender 2.5 alpha 0
authorCampbell Barton <ideasman42@gmail.com>
Mon, 7 Dec 2009 10:41:16 +0000 (10:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 7 Dec 2009 10:41:16 +0000 (10:41 +0000)
could not redo the bug on my system, fix suggested by Yomgui on blendercoders.

source/blender/python/intern/bpy_interface.c

index 9a14717b060f58f12b21123e8e5700653c61bd41..d4d0cbf602fbbd103b929082a8a53072c6182b38 100644 (file)
@@ -313,11 +313,25 @@ void BPY_start_python( int argc, char **argv )
        /* sigh, why do python guys not have a char** version anymore? :( */
        {
                int i;
+#if 0
                PyObject *py_argv= PyList_New(argc);
-
                for (i=0; i<argc; i++)
                        PyList_SET_ITEM(py_argv, i, PyUnicode_FromString(argv[i]));
 
+#else  // should fix bug #20021 - utf path name problems
+               PyObject *py_argv= PyList_New(0);
+               for (i=0; i<argc; i++) {
+                       PyObject *item= PyUnicode_Decode(argv[i], strlen(argv[i]), Py_FileSystemDefaultEncoding, NULL);
+                       if(item==NULL) { // should never happen
+                               PyErr_Print();
+                               PyErr_Clear();
+                       }
+                       else {
+                               PyList_Append(py_argv, item);
+                               Py_DECREF(item);
+                       }
+               }
+#endif
                PySys_SetObject("argv", py_argv);
                Py_DECREF(py_argv);
        }