Browse Source

Init: A workaround for Python Issue30755

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71807 15284696-431f-4ddb-bdfa-cd5b030d7da7
Maris Nartiss 7 years ago
parent
commit
c20d341646
1 changed files with 12 additions and 0 deletions
  1. 12 0
      lib/init/grass.py

+ 12 - 0
lib/init/grass.py

@@ -1160,6 +1160,18 @@ def set_language(grass_config_dir):
                 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