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 3, 2022
1 parent ccf7607 commit e01e2bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 e01e2bc

Please sign in to comment.