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)
This commit is contained in:
2012-03-21 22:29:49 +00:00
parent 95f66f162c
commit b56d2f9766
6 changed files with 39 additions and 27 deletions

View File

@@ -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);