fix(config): read YAML config files as UTF-8 (#124)
_load_yaml opened config files with the platform default (locale) encoding instead of UTF-8. The shipped configs (e.g. configs/_base_/default.yaml) contain UTF-8 non-ASCII characters (em-dash, arrows, box-drawing), so load_config() raises UnicodeDecodeError on any non-UTF-8 locale (e.g. Windows cp936/cp1252), breaking scripts/train.py and scripts/eval_only.py before startup. YAML is UTF-8 by spec, and the rest of the codebase already opens text files with encoding="utf-8". Pass encoding="utf-8" here for parity.
This commit is contained in:
+1
-1
@@ -158,7 +158,7 @@ def _load_yaml(path: str, _visited: set[str] | None = None) -> dict:
|
||||
raise ValueError(f"Circular _base_ inheritance: {abs_path}")
|
||||
_visited.add(abs_path)
|
||||
|
||||
with open(abs_path) as f:
|
||||
with open(abs_path, encoding="utf-8") as f:
|
||||
cfg = yaml.safe_load(f) or {}
|
||||
|
||||
base_ref = cfg.pop("_base_", None)
|
||||
|
||||
Reference in New Issue
Block a user