# HG changeset patch # User Thomas De Schampheleire # Date 1561398122 -7200 # Node ID f2900ebaac0d98c0310a4f6494c70a60d0c1b4e7 # Parent a512e843cd316344bac35c3e3db84c674525b605 locale: fix environment checks: LC_ALL has precedence over LC_CTYPE 'man 7 locale' describes following precedence: If the second argument to setlocale(3) is an empty string, "", for the default locale, it is determined using the following steps: 1. If there is a non-null environment variable LC_ALL, the value of LC_ALL is used. 2. If an environment variable with the same name as one of the categories above exists and is non-null, its value is used for that category. 3. If there is a non-null environment variable LANG, the value of LANG is used. So, if LC_ALL is set, it is used regardless of LC_CTYPE or LANG. Hence, when suggesting users what to change when their locale is invalid, we should also first check LC_ALL instead of LC_CTYPE. diff -r a512e843cd31 -r f2900ebaac0d kallithea/config/app_cfg.py --- a/kallithea/config/app_cfg.py Wed May 01 02:50:55 2019 +0200 +++ b/kallithea/config/app_cfg.py Mon Jun 24 19:42:02 2019 +0200 @@ -127,7 +127,7 @@ u'\xe9'.encode(sys.getfilesystemencoding()) # Test using é (é) except UnicodeEncodeError: log.error("Cannot encode Unicode paths to file system encoding %r", sys.getfilesystemencoding()) - for var in ['LC_CTYPE', 'LC_ALL', 'LANG']: + for var in ['LC_ALL', 'LC_CTYPE', 'LANG']: if var in os.environ: val = os.environ[var] log.error("Note: Environment variable %s is %r - perhaps change it to some other value from 'locale -a', like 'C.UTF-8' or 'en_US.UTF-8'", var, val)