Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix config encoding #653

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mmengine/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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):
Expand Down