From 7672b543f8c62da34f0bb11be17d5e6d336cb2da Mon Sep 17 00:00:00 2001 From: Ade Lee Date: Tue, 11 Apr 2017 23:04:34 -0400 Subject: Fix python issues identified in review subprocess returns bytes in Python 3. Make sure to decode first when returning env variables. Change-Id: I225044c0463f0a84ac5ffb77b28391fac269598d --- base/common/python/pki/util.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'base/common/python') diff --git a/base/common/python/pki/util.py b/base/common/python/pki/util.py index 0de13fd93..5832f5562 100644 --- a/base/common/python/pki/util.py +++ b/base/common/python/pki/util.py @@ -258,10 +258,9 @@ def read_environment_files(env_file_list=None): if env_file_list is None: env_file_list = DEFAULT_PKI_ENV_LIST - file_command = '' - for env_file in env_file_list: - file_command += "source " + env_file + " && " - file_command += "env" + file_command = ' && '.join( + 'source {}'.format(env_file) for env_file in env_file_list) + file_command += ' && env' command = [ 'bash', @@ -269,7 +268,7 @@ def read_environment_files(env_file_list=None): file_command ] - env_vals = subprocess.check_output(command).split('\n') + env_vals = subprocess.check_output(command).decode('utf-8').split('\n') for env_val in env_vals: (key, _, value) = env_val.partition("=") -- cgit