File blender-2.56-svn35395.patch of Package blender
Index: source/blender/python/generic/py_capi_utils.c
===================================================================
--- source/blender/python/generic/py_capi_utils.c.orig 2011-04-28 23:38:45.571745571 +0200
+++ source/blender/python/generic/py_capi_utils.c 2011-04-28 23:39:03.621288102 +0200
@@ -241,7 +241,29 @@ const char *PyC_UnicodeAsByte(PyObject *
return PyBytes_AS_STRING(py_str);
}
else {
- return PyBytes_AS_STRING((*coerce= PyUnicode_EncodeFSDefault(py_str)));
+ /* mostly copied from fileio.c's, fileio_init */
+ PyObject *stringobj;
+ PyObject *u;
+
+ PyErr_Clear();
+
+ u= PyUnicode_FromObject(py_str); /* coerce into unicode */
+
+ if (u == NULL)
+ return NULL;
+
+ stringobj= PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(u), PyUnicode_GET_SIZE(u), "surrogateescape");
+ Py_DECREF(u);
+ if (stringobj == NULL)
+ return NULL;
+ if (!PyBytes_Check(stringobj)) { /* this seems wrong but it works fine */
+ // printf("encoder failed to return bytes\n");
+ Py_DECREF(stringobj);
+ return NULL;
+ }
+ *coerce= stringobj;
+
+ return PyBytes_AS_STRING(stringobj);
}
}