Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError #54

Closed
moridew opened this issue Jul 13, 2022 · 5 comments
Closed

UnicodeDecodeError #54

moridew opened this issue Jul 13, 2022 · 5 comments

Comments

@moridew
Copy link

moridew commented Jul 13, 2022

Hello.
Thank you for your kindness.

The following error occurs:

Logger: homeassistant.config_entries
Source: custom_components/watchman/utils.py:255
Integration: Watchman (documentation, issues)
First occurred: 11:19:42 (1 occurrences)
Last logged: 11:19:42

Error setting up entry Watchman for watchman
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 339, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/watchman/init.py", line 137, in async_setup_entry
parse_config(hass, reason="changes in watchman configuration")
File "/config/custom_components/watchman/init.py", line 345, in parse_config
entity_list, service_list, files_parsed, files_ignored = parse(
File "/config/custom_components/watchman/utils.py", line 255, in parse
for i, line in enumerate(open(yaml_file, encoding="utf-8")):
File "/usr/local/lib/python3.9/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 32: invalid start byte

@Opontios
Copy link

Opontios commented Jan 8, 2023

Same thing here. Any way to resolve?

Logger: homeassistant
Source: custom_components/watchman/utils.py:255
Integration: Watchman ([documentation](https://github.com/dummylabs/thewatchman), [issues](https://github.com/dummylabs/thewatchman/issues))
First occurred: 15:09:52 (1 occurrences)
Last logged: 15:09:52
Error doing job: Task exception was never retrieved

Traceback (most recent call last):
  File "/config/custom_components/watchman/__init__.py", line 268, in async_on_home_assistant_started
    parse_config(hass, reason="HA restart")
  File "/config/custom_components/watchman/__init__.py", line 345, in parse_config
    entity_list, service_list, files_parsed, files_ignored = parse(
  File "/config/custom_components/watchman/utils.py", line 255, in parse
    for i, line in enumerate(open(yaml_file, encoding="utf-8")):
  File "/usr/local/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 108: invalid continuation byte 

@moridew
Copy link
Author

moridew commented Jan 8, 2023

An error occurs when the annotation is utf8. The utf8 annotation has been deleted and normalized.

@moridew moridew closed this as completed Jan 8, 2023
@Opontios
Copy link

Opontios commented Jan 8, 2023

What exactly is the annotation?

@moridew
Copy link
Author

moridew commented Jan 8, 2023

You had to comment all .yaml files in English only. All yaml files in the subdirectory, including files in the config folder.

@dummylabs
Copy link
Owner

Any other language should work fine for comments, not just English. The important condition is to explicitly save file with UTF-8 encoding in your text editor. I've added a yaml file with UTF-8 comments to the automated tests, it works just fine with current version (0.6.0)

On top of that, starting from 0.6.1 (not yet released) files with encodings other than UTF-8 will not cause Watchman to crash, it will report error message to the log instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants