Fix #111033: Crash on startup when Blender path isn't UTF8 compatible
This commit is contained in:
@@ -96,7 +96,11 @@ PyObject *PyC_Tuple_PackArray_Multi_Bool(const bool *array, const int dims[], in
|
||||
void PyC_Tuple_Fill(PyObject *tuple, PyObject *value);
|
||||
void PyC_List_Fill(PyObject *list, PyObject *value);
|
||||
|
||||
/* follow http://www.python.org/dev/peps/pep-0383/ */
|
||||
/**
|
||||
* Create a `str` from bytes in a way which is compatible with non UTF8 encoded file-system paths,
|
||||
* see: #111033.
|
||||
* Follow http://www.python.org/dev/peps/pep-0383/
|
||||
*/
|
||||
PyObject *PyC_UnicodeFromBytes(const char *str);
|
||||
/**
|
||||
* \param size: The length of the string: `strlen(str)`.
|
||||
|
||||
@@ -641,7 +641,7 @@ void BPy_init_modules(bContext *C)
|
||||
if (modpath) {
|
||||
// printf("bpy: found module path '%s'.\n", modpath);
|
||||
PyObject *sys_path = PySys_GetObject("path"); /* borrow */
|
||||
PyObject *py_modpath = PyUnicode_FromString(modpath);
|
||||
PyObject *py_modpath = PyC_UnicodeFromBytes(modpath);
|
||||
PyList_Insert(sys_path, 0, py_modpath); /* add first */
|
||||
Py_DECREF(py_modpath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user