1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 20:35:55 +00:00

Catch unicode decode errors (#4651)

Yaml loader did not catch unicode decode errors as json loader did.

Related to: https://github.com/home-assistant/core/issues/102818
This commit is contained in:
Joakim Plate
2023-10-26 09:27:05 +02:00
committed by GitHub
parent 059c0df16c
commit 7361d39231

View File

@@ -21,7 +21,7 @@ def read_yaml_file(path: Path) -> dict:
with open(path, encoding="utf-8") as yaml_file:
return load(yaml_file, Loader=SafeLoader) or {}
except (YAMLError, AttributeError, OSError) as err:
except (YAMLError, AttributeError, OSError, UnicodeDecodeError) as err:
raise YamlFileError(
f"Can't read YAML file {path!s} - {err!s}", _LOGGER.error
) from err