[GRASS-SVN] r71807 - grass/trunk/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 23 01:02:43 PST 2017


Author: marisn
Date: 2017-11-23 01:02:43 -0800 (Thu, 23 Nov 2017)
New Revision: 71807

Modified:
   grass/trunk/lib/init/grass.py
Log:
Init: A workaround for Python Issue30755


Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py	2017-11-23 04:05:58 UTC (rev 71806)
+++ grass/trunk/lib/init/grass.py	2017-11-23 09:02:43 UTC (rev 71807)
@@ -1160,6 +1160,18 @@
                 locale.setlocale(locale.LC_ALL, normalized)
             except locale.Error as e:
                 if language == 'en':
+                    # A workaround for Python Issue30755
+                    # https://bugs.python.org/issue30755
+                    if locale.normalize('C.UTF-8') == 'en_US.UTF-8':
+                        locale.setlocale(locale.LC_ALL, 'C')
+                        os.environ['LANGUAGE'] = 'C'
+                        os.environ['LANG'] = 'C'
+                        os.environ['LC_MESSAGES'] = 'C'
+                        os.environ['LC_NUMERIC'] = 'C'
+                        os.environ['LC_TIME'] = 'C'
+                        sys.stderr.write("To avoid Unicode errors in GUI, install en_US.UTF-8 locale and restart GRASS.\n"
+                        "Also consider upgrading your Python version to one containg fix for Python Issue 30755.\n")
+                        return
                     # en_US locale might be missing, still all messages in
                     # GRASS are already in en_US language.
                     # Using plain C as locale forces encodings to ascii



More information about the grass-commit mailing list