mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 01:08:03 +01:00
Fix validation TypeError (#574)
This commit is contained in:
parent
1ce257c721
commit
27abb38ecb
1 changed files with 4 additions and 0 deletions
|
@ -78,8 +78,12 @@ def indexbytes(buf, i):
|
||||||
if IS_PY2:
|
if IS_PY2:
|
||||||
def decode_text(data, encoding='utf-8', errors='strict'):
|
def decode_text(data, encoding='utf-8', errors='strict'):
|
||||||
# type: (str, str, str) -> unicode
|
# type: (str, str, str) -> unicode
|
||||||
|
if isinstance(data, unicode):
|
||||||
|
return data
|
||||||
return unicode(data, encoding=encoding, errors=errors)
|
return unicode(data, encoding=encoding, errors=errors)
|
||||||
else:
|
else:
|
||||||
def decode_text(data, encoding='utf-8', errors='strict'):
|
def decode_text(data, encoding='utf-8', errors='strict'):
|
||||||
# type: (bytes, str, str) -> str
|
# type: (bytes, str, str) -> str
|
||||||
|
if isinstance(data, str):
|
||||||
|
return data
|
||||||
return data.decode(encoding=encoding, errors=errors)
|
return data.decode(encoding=encoding, errors=errors)
|
||||||
|
|
Loading…
Reference in a new issue