diff --git a/core/utils/envs.py b/core/utils/envs.py index bfc18b148e9db719f0dff6cda7e5fee4f7ee2d2d..29403420f94e2205226d9c857922fd07ce19eb3e 100755 --- a/core/utils/envs.py +++ b/core/utils/envs.py @@ -19,6 +19,7 @@ import os import socket import sys import traceback +import six global_envs = {} global_envs_flatten = {} @@ -253,11 +254,19 @@ def load_yaml(config): use_full_loader = False if os.path.isfile(config): - with open(config, 'r') as rb: - if use_full_loader: - _config = yaml.load(rb.read(), Loader=yaml.FullLoader) - else: - _config = yaml.load(rb.read()) - return _config + if six.PY2: + with open(config, 'r') as rb: + if use_full_loader: + _config = yaml.load(rb.read(), Loader=yaml.FullLoader) + else: + _config = yaml.load(rb.read()) + return _config + else: + with open(config, 'r', encoding="utf-8") as rb: + if use_full_loader: + _config = yaml.load(rb.read(), Loader=yaml.FullLoader) + else: + _config = yaml.load(rb.read()) + return _config else: raise ValueError("config {} can not be supported".format(config))