From 4f2976941fd7284c85e89c1de5038805e62a5c99 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Mar 2012 03:14:38 +0000 Subject: fix for issue raise by patch [#30154] non utf8 buildinfo, fails to import 'bpy' module. we cant ensure buildinfo to have utf8 encoding so access it as bytes via python - a different workaround then this patch made. also use C style string formatting for sys_info.py --- source/blender/python/intern/bpy_app.c | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 0641c220001..7cd672ba0c5 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -108,6 +108,8 @@ static PyObject *make_app_info(void) PyStructSequence_SET_ITEM(app_info, pos++, PyLong_FromLong(flag)) #define SetStrItem(str) \ PyStructSequence_SET_ITEM(app_info, pos++, PyUnicode_FromString(str)) +#define SetBytesItem(str) \ + PyStructSequence_SET_ITEM(app_info, pos++, PyBytes_FromString(str)) #define SetObjItem(obj) \ PyStructSequence_SET_ITEM(app_info, pos++, obj) @@ -121,27 +123,28 @@ static PyObject *make_app_info(void) SetStrItem(BLI_program_path()); SetObjItem(PyBool_FromLong(G.background)); - /* build info */ + /* build info, use bytes since we can't assume _any_ encoding: + * see patch [#30154] for issue */ #ifdef BUILD_DATE - SetStrItem(build_date); - SetStrItem(build_time); - SetStrItem(build_rev); - SetStrItem(build_platform); - SetStrItem(build_type); - SetStrItem(build_cflags); - SetStrItem(build_cxxflags); - SetStrItem(build_linkflags); - SetStrItem(build_system); + SetBytesItem(build_date); + SetBytesItem(build_time); + SetBytesItem(build_rev); + SetBytesItem(build_platform); + SetBytesItem(build_type); + SetBytesItem(build_cflags); + SetBytesItem(build_cxxflags); + SetBytesItem(build_linkflags); + SetBytesItem(build_system); #else - SetStrItem("Unknown"); - SetStrItem("Unknown"); - SetStrItem("Unknown"); - SetStrItem("Unknown"); - SetStrItem("Unknown"); - SetStrItem("Unknown"); - SetStrItem("Unknown"); - SetStrItem("Unknown"); - SetStrItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); #endif SetObjItem(BPY_app_ffmpeg_struct()); @@ -149,6 +152,7 @@ static PyObject *make_app_info(void) #undef SetIntItem #undef SetStrItem +#undef SetBytesItem #undef SetObjItem if (PyErr_Occurred()) { -- cgit v1.2.3