From 47e209bdebabe78cb737116d0af3e8278b30a4d9 Mon Sep 17 00:00:00 2001 From: gentelyang <852221609@qq.com> Date: Wed, 17 Jun 2020 15:39:44 +0800 Subject: [PATCH] fix win py3 --- core/utils/envs.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/core/utils/envs.py b/core/utils/envs.py index bfc18b14..29403420 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)) -- GitLab