[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50412] trunk/blender/source/blender/ python/intern/bpy_interface.c: fix/workaround [#31555] Username with special chars in Windows 7

Campbell Barton ideasman42 at gmail.com
Wed Sep 5 11:33:15 CEST 2012


Revision: 50412
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50412
Author:   campbellbarton
Date:     2012-09-05 09:33:15 +0000 (Wed, 05 Sep 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_interface.c

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c	2012-09-05 08:50:25 UTC (rev 50411)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c	2012-09-05 09:33:15 UTC (rev 50412)
@@ -254,6 +254,15 @@
 
 	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? */
 	{




More information about the Bf-blender-cvs mailing list