Skip to content

Commit 947395b

Browse files
authored
Merge pull request #102 from gentelyang/master
fix win py3
2 parents cd2f8f9 + 47e209b commit 947395b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

core/utils/envs.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import socket
2020
import sys
2121
import traceback
22+
import six
2223

2324
global_envs = {}
2425
global_envs_flatten = {}
@@ -253,11 +254,19 @@ def load_yaml(config):
253254
use_full_loader = False
254255

255256
if os.path.isfile(config):
256-
with open(config, 'r') as rb:
257-
if use_full_loader:
258-
_config = yaml.load(rb.read(), Loader=yaml.FullLoader)
259-
else:
260-
_config = yaml.load(rb.read())
261-
return _config
257+
if six.PY2:
258+
with open(config, 'r') as rb:
259+
if use_full_loader:
260+
_config = yaml.load(rb.read(), Loader=yaml.FullLoader)
261+
else:
262+
_config = yaml.load(rb.read())
263+
return _config
264+
else:
265+
with open(config, 'r', encoding="utf-8") as rb:
266+
if use_full_loader:
267+
_config = yaml.load(rb.read(), Loader=yaml.FullLoader)
268+
else:
269+
_config = yaml.load(rb.read())
270+
return _config
262271
else:
263272
raise ValueError("config {} can not be supported".format(config))

0 commit comments

Comments
 (0)