Skip to content

Commit

Permalink
bluezdbus/manager: ignore KeyError when properties removed
Browse files Browse the repository at this point in the history
Apparently, BlueZ will sometimes request to remove properties that
were not set in the first place.

Fixes: #1107
  • Loading branch information
dlech committed Nov 6, 2022
1 parent 431cfc9 commit 9c9dac6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -14,6 +14,7 @@ Fixed
------
* Fixed crash when getting services in WinRT backend.
* Fixed cache mode when retrying get services in WinRT backend.
* Fixed ``KeyError`` crash in BlueZ backend when removing non-existent property. Fixes #1107.

`0.19.1`_ (2022-10-29)
======================
Expand Down
7 changes: 6 additions & 1 deletion bleak/backends/bluezdbus/manager.py
Expand Up @@ -818,7 +818,12 @@ def _parse_msg(self, message: Message):
self_interface.update(unpack_variants(changed))

for name in invalidated:
del self_interface[name]
try:
del self_interface[name]
except KeyError:
# sometimes there BlueZ tries to remove properties
# that were never added
pass

# then call any callbacks so they will be called with the
# updated state
Expand Down

0 comments on commit 9c9dac6

Please sign in to comment.