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):