Fix T40766: Startup fails with UnicodeDecodeError on Windows

This commit is contained in:
Campbell Barton 2014-08-11 17:53:42 +10:00
parent 1528e5c20a
commit d4599ff001
2 changed files with 11 additions and 8 deletions

@ -51,12 +51,15 @@
#include "bpy_operator.h"
#include "bpy_utils_units.h"
#include "../generic/py_capi_utils.h"
#include "MEM_guardedalloc.h"
/* external util modules */
#include "../generic/idprop_py_api.h"
#include "../generic/bgl.h"
#include "../generic/blf_py_api.h"
#include "../generic/blf_py_api.h"
#include "../mathutils/mathutils.h"
#ifdef WITH_FREESTYLE
@ -80,11 +83,11 @@ static PyObject *bpy_script_paths(PyObject *UNUSED(self))
const char *path;
path = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL);
item = PyUnicode_DecodeFSDefault(path ? path : "");
item = PyC_UnicodeFromByte(path ? path : "");
BLI_assert(item != NULL);
PyTuple_SET_ITEM(ret, 0, item);
path = BLI_get_folder(BLENDER_USER_SCRIPTS, NULL);
item = PyUnicode_DecodeFSDefault(path ? path : "");
item = PyC_UnicodeFromByte(path ? path : "");
BLI_assert(item != NULL);
PyTuple_SET_ITEM(ret, 1, item);
@ -94,7 +97,7 @@ static PyObject *bpy_script_paths(PyObject *UNUSED(self))
static bool bpy_blend_paths_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
{
PyObject *list = (PyObject *)userdata;
PyObject *item = PyUnicode_DecodeFSDefault(path_src);
PyObject *item = PyC_UnicodeFromByte(path_src);
PyList_Append(list, item);
Py_DECREF(item);
return false; /* never edits the path */
@ -171,7 +174,7 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
if (!path)
path = BLI_get_user_folder_notest(folder_id, subdir);
return PyUnicode_DecodeFSDefault(path ? path : "");
return PyC_UnicodeFromByte(path ? path : "");
}
PyDoc_STRVAR(bpy_resource_path_doc,
@ -210,7 +213,7 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
path = BLI_get_folder_version(folder_id, (major * 100) + minor, false);
return PyUnicode_DecodeFSDefault(path ? path : "");
return PyC_UnicodeFromByte(path ? path : "");
}
PyDoc_STRVAR(bpy_escape_identifier_doc,

@ -257,7 +257,7 @@ static PyObject *gPyExpandPath(PyObject *, PyObject *args)
BLI_strncpy(expanded, filename, FILE_MAX);
BLI_path_abs(expanded, gp_GamePythonPath);
return PyUnicode_DecodeFSDefault(expanded);
return PyC_UnicodeFromByte(expanded);
}
static char gPyStartGame_doc[] =
@ -546,7 +546,7 @@ static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args)
while ((dirp = readdir(dp)) != NULL) {
if (BLI_testextensie(dirp->d_name, ".blend")) {
value= PyUnicode_DecodeFSDefault(dirp->d_name);
value = PyC_UnicodeFromByte(dirp->d_name);
PyList_Append(list, value);
Py_DECREF(value);
}
@ -1974,7 +1974,7 @@ static void initPySysObjects__append(PyObject *sys_path, const char *filename)
BLI_split_dir_part(filename, expanded, sizeof(expanded)); /* get the dir part of filename only */
BLI_path_abs(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */
BLI_cleanup_file(gp_GamePythonPath, expanded); /* Don't use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */
item= PyUnicode_DecodeFSDefault(expanded);
item = PyC_UnicodeFromByte(expanded);
// printf("SysPath - '%s', '%s', '%s'\n", expanded, filename, gp_GamePythonPath);