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

Campbell Barton ideasman42 at gmail.com
Mon Dec 3 11:01:13 CET 2012


Revision: 52739
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52739
Author:   campbellbarton
Date:     2012-12-03 10:01:09 +0000 (Mon, 03 Dec 2012)
Log Message:
-----------
re-apply a workaround for [#31555] Username with special chars in Windows 7
this time keep the stderr/stdout so there FD's are not closed (causing [#32720]).

This workaround is ugly but saves us from using a patched python.

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-12-03 09:55:18 UTC (rev 52738)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c	2012-12-03 10:01:09 UTC (rev 52739)
@@ -268,6 +268,19 @@
 
 	Py_Initialize();
 
+	/* THIS IS BAD: see http://bugs.python.org/issue16129 */
+#if 1
+	/* until python provides a reliable way to set the env var */
+	PyRun_SimpleString("import sys, io\n"
+	                   "sys.__backup_stdio__ = sys.__stdout__, sys.__stderr__\n"  /* else we loose the FD's [#32720] */
+	                   "sys.__stdout__ = sys.stdout = io.TextIOWrapper(io.open(sys.stdout.fileno(), 'wb', -1), "
+	                   "encoding='utf-8', errors='surrogateescape', newline='\\n', line_buffering=True)\n"
+	                   "sys.__stderr__ = sys.stderr = io.TextIOWrapper(io.open(sys.stderr.fileno(), 'wb', -1), "
+	                   "ncoding='utf-8', errors='surrogateescape', newline='\\n', line_buffering=True)\n");
+#endif
+	/* end the baddness */
+
+
 	// 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