diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-22 02:29:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-22 02:29:49 +0400 |
commit | b56d2f97662e0277076b7a7fd1f7a19380dc9f63 (patch) | |
tree | e2bb3fb3affd60a14229fd38098a3c804a8e3b03 /source | |
parent | 95f66f162ce695310872950232b6a00633646e1e (diff) |
fix [#30623] user-defined render presets bug
this report exposed multiple bugs in blender when using a non utf8 compatible home directory.
- bpy.utils.script_paths() would crash when homedir wasn't utf8 (reported bug)
- PyC_DefaultNameSpace() - would raise an error when running when __file__ was non utf8.
- preset filepath property was not set to accept non utf8.
- bpy.paths.display_name would raise an error on non utf8 paths, (used for preset draw)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/bmesh.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_edit.c | 2 | ||||
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 6 | ||||
-rw-r--r-- | source/blender/python/intern/bpy.c | 11 |
4 files changed, 13 insertions, 7 deletions
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index 59b96cafca0..2e568a15117 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -222,7 +222,6 @@ extern "C" { #include "intern/bmesh_polygon.h" #include "intern/bmesh_queries.h" #include "intern/bmesh_walkers.h" -#include "intern/bmesh_walkers.h" #include "intern/bmesh_inline.c" #include "intern/bmesh_operator_api_inline.c" diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 7702e952e24..c752b86c1e8 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -80,7 +80,7 @@ void SCRIPT_OT_python_file_run(wmOperatorType *ot) ot->exec= run_pyfile_exec; ot->poll= ED_operator_areaactive; - RNA_def_string_file_path(ot->srna, "filepath", "", 512, "Path", ""); + RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "Path", ""); } diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index fdb5f629115..c670f728cb9 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -437,8 +437,10 @@ PyObject *PyC_DefaultNameSpace(const char *filename) PyDict_SetItemString(interp->modules, "__main__", mod_main); Py_DECREF(mod_main); /* sys.modules owns now */ PyModule_AddStringConstant(mod_main, "__name__", "__main__"); - if (filename) - PyModule_AddStringConstant(mod_main, "__file__", filename); /* __file__ only for nice UI'ness */ + if (filename) { + /* __file__ mainly for nice UI'ness */ + PyModule_AddObject(mod_main, "__file__", PyUnicode_DecodeFSDefault(filename)); + } PyModule_AddObject(mod_main, "__builtins__", interp->builtins); Py_INCREF(interp->builtins); /* AddObject steals a reference */ return PyModule_GetDict(mod_main); diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 0f5ca13586c..71cfa50743d 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -71,12 +71,17 @@ PyDoc_STRVAR(bpy_script_paths_doc, static PyObject *bpy_script_paths(PyObject *UNUSED(self)) { PyObject *ret = PyTuple_New(2); + PyObject *item; char *path; path = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL); - PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(path?path:"")); + item = PyUnicode_DecodeFSDefault(path ? path : ""); + BLI_assert(item != NULL); + PyTuple_SET_ITEM(ret, 0, item); path = BLI_get_folder(BLENDER_USER_SCRIPTS, NULL); - PyTuple_SET_ITEM(ret, 1, PyUnicode_FromString(path?path:"")); + item = PyUnicode_DecodeFSDefault(path ? path : ""); + BLI_assert(item != NULL); + PyTuple_SET_ITEM(ret, 1, item); return ret; } @@ -200,7 +205,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); + return PyUnicode_DecodeFSDefault(path ? path : ""); } static PyMethodDef meth_bpy_script_paths = |