Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-09-05 13:33:15 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-05 13:33:15 +0400
commite2eea6c38dc787677eb0cfeebbaee56fff65989f (patch)
treebc04699b3c3da4fd8d12e2fe3b85d91b2354e4ea /source/blender/python
parent7efe2153b2a04322b312cacba60168c0db470f95 (diff)
fix/workaround [#31555] Username with special chars in Windows 7
Theres a bug where python/windows ignores PYTHONIOENCODING, workaround this by manually overriding the stdout/stderr.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_interface.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index aa9d81389da..1c63ab512f2 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -254,6 +254,15 @@ void BPY_python_start(int argc, const char **argv)
Py_Initialize();
+#ifdef WIN32
+ /* this is disappointing, its likely a bug in python?
+ * for some reason 'PYTHONIOENCODING' is ignored in windows
+ * see: [#31555] for details. */
+ PyRun_SimpleString("import sys, io\n"
+ "sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='surrogateescape', line_buffering=True)\n"
+ "sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='surrogateescape', line_buffering=True)\n");
+#endif /* WIN32 */
+
// PySys_SetArgv(argc, argv); // broken in py3, not a huge deal
/* sigh, why do python guys not have a (char **) version anymore? */
{