From 59091100e46d02f8845de21b6cd2f809e1a4eb66 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 30 Jun 2019 12:19:03 +0200 Subject: [PATCH] Fix YAMLError with unicode --- esphome/config.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/esphome/config.py b/esphome/config.py index b5075e5e84..9141341c61 100644 --- a/esphome/config.py +++ b/esphome/config.py @@ -18,7 +18,7 @@ from esphome.components.substitutions import CONF_SUBSTITUTIONS from esphome.const import CONF_ESPHOME, CONF_PLATFORM, ESP_PLATFORMS from esphome.core import CORE, EsphomeError # noqa from esphome.helpers import color, indent -from esphome.py_compat import text_type, IS_PY2 +from esphome.py_compat import text_type, IS_PY2, decode_text from esphome.util import safe_print, OrderedDict from typing import List, Optional, Tuple, Union # noqa @@ -634,8 +634,13 @@ def _format_vol_invalid(ex, config): class InvalidYAMLError(EsphomeError): def __init__(self, base_exc): + try: + base = str(base_exc) + except UnicodeDecodeError: + base = repr(base_exc) + base = decode_text(base) message = u"Invalid YAML syntax. Please see YAML syntax reference or use an " \ - u"online YAML syntax validator:\n\n{}".format(base_exc) + u"online YAML syntax validator:\n\n{}".format(base) super(InvalidYAMLError, self).__init__(message) self.base_exc = base_exc @@ -798,7 +803,7 @@ def strip_default_ids(config): def read_config(verbose): - _LOGGER.info("Reading configuration...") + _LOGGER.info("Reading configuration %s...", CORE.config_path) try: res = load_config() except EsphomeError as err: