From fba154dec2294e7233b752e8d837d4fe8550fa3d Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Thu, 26 Oct 2023 08:23:58 +0200 Subject: [PATCH] Catch unicode decode errors Yaml loader did not catch unicode decode errors as json loader did. Related to: https://github.com/home-assistant/core/issues/102818 --- supervisor/utils/yaml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/utils/yaml.py b/supervisor/utils/yaml.py index eac1837777e..544f897056c 100644 --- a/supervisor/utils/yaml.py +++ b/supervisor/utils/yaml.py @@ -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