From fe4ee84cf1789a8e13cf2a211e4192b1d61a65fa Mon Sep 17 00:00:00 2001 From: sanbuphy Date: Mon, 31 Oct 2022 15:44:53 +0800 Subject: [PATCH] fix config encoding --- mmengine/config/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmengine/config/config.py b/mmengine/config/config.py index 860b60b448..c84493d283 100644 --- a/mmengine/config/config.py +++ b/mmengine/config/config.py @@ -418,7 +418,7 @@ def _file2dict(filename: str, base_cfg_dict.update(_cfg_dict) if filename.endswith('.py'): - with open(temp_config_file.name) as f: + with open(temp_config_file.name, encoding='utf-8') as f: codes = ast.parse(f.read()) codes = RemoveAssignFromAST(BASE_KEY).visit(codes) codeobj = compile(codes, '', mode='exec') @@ -550,7 +550,7 @@ def _get_base_files(filename: str) -> list: file_format = filename.partition('.')[-1] if file_format == 'py': Config._validate_py_syntax(filename) - with open(filename) as f: + with open(filename, encoding='utf-8') as f: codes = ast.parse(f.read()).body def is_base_line(c):