[GRASS-SVN] r73242 - grass/trunk/gui/wxpython/core

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 3 19:28:54 PDT 2018


Author: annakrat
Date: 2018-09-03 19:28:53 -0700 (Mon, 03 Sep 2018)
New Revision: 73242

Modified:
   grass/trunk/gui/wxpython/core/gconsole.py
Log:
wxGUI: fix debug mode with Python 3

Modified: grass/trunk/gui/wxpython/core/gconsole.py
===================================================================
--- grass/trunk/gui/wxpython/core/gconsole.py	2018-09-03 21:14:23 UTC (rev 73241)
+++ grass/trunk/gui/wxpython/core/gconsole.py	2018-09-04 02:28:53 UTC (rev 73242)
@@ -402,8 +402,13 @@
         else:
             enc = locale.getdefaultlocale()[1]
             if enc:
-                sys.stdout = codecs.getwriter(enc)(sys.__stdout__)
-                sys.stderr = codecs.getwriter(enc)(sys.__stderr__)
+                if sys.version_info.major == 2:
+                    sys.stdout = codecs.getwriter(enc)(sys.__stdout__)
+                    sys.stderr = codecs.getwriter(enc)(sys.__stderr__)
+                else:
+                    # https://stackoverflow.com/questions/4374455/how-to-set-sys-stdout-encoding-in-python-3
+                    sys.stdout = codecs.getwriter(enc)(sys.__stdout__.detach())
+                    sys.stderr = codecs.getwriter(enc)(sys.__stderr__.detach())
             else:
                 sys.stdout = sys.__stdout__
                 sys.stderr = sys.__stderr__



More information about the grass-commit mailing list