aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/utils.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-11 23:00:15 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-12 08:21:12 +0100
commit8902c29638411d312e6fc4a197707e5742652e15 (patch)
treee4d37a601ea654862b756131b040c882a2ae3129 /lib/bb/utils.py
parent1ffd8737e065a3cd634c74cd67e634d785ea93a5 (diff)
downloadbitbake-8902c29638411d312e6fc4a197707e5742652e15.tar.gz
utils: Force bitbake to en_US.UTF-8 locale setting everywhere
Under python 3, if we spawn python processes, we need to have a UTF-8 locale, else python's file access methods will use ascii. You can't change that mode once the interpreter is started so we have to ensure a locale is set. Ideally we'd use C.UTF-8 since OE already forces the C locale but not all distros support that and we need to set something. Was tempted to choose en_GB so colour gets spelt correctly :). This is in some ways pretty nasty, forcing it into the environment everywhere however we only have a limited number of ways of making everything work correctly and this beats having to add utf-8 encoding to every file access command. A similar change will be needed to bitbake.conf in OE. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r--lib/bb/utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 0c553dd76..588c192c0 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -568,6 +568,7 @@ def preserved_envvars_exported():
'SHELL',
'TERM',
'USER',
+ 'LC_ALL',
]
def preserved_envvars():
@@ -595,6 +596,12 @@ def filter_environment(good_vars):
os.unsetenv(key)
del os.environ[key]
+ # If we spawn a python process, we need to have a UTF-8 locale, else python's file
+ # access methods will use ascii. You can't change that mode once the interpreter is
+ # started so we have to ensure a locale is set. Ideally we'd use C.UTF-8 but not all
+ # distros support that and we need to set something.
+ os.environ["LC_ALL"] = "en_US.UTF-8"
+
if removed_vars:
logger.debug(1, "Removed the following variables from the environment: %s", ", ".join(removed_vars.keys()))