From 461fd3afa41deb534ef5399bbcd01e30adb83d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gl=C3=A4=C3=9Fle?= Date: Tue, 3 Oct 2023 13:51:26 +0200 Subject: [PATCH] Fix KeyError when properties are invalidated multiple times Fixes #272 --- udiskie/udisks2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/udiskie/udisks2.py b/udiskie/udisks2.py index d419cab..509022c 100644 --- a/udiskie/udisks2.py +++ b/udiskie/udisks2.py @@ -862,7 +862,10 @@ def _properties_changed(self, # update device state: old_state = deepcopy(self._objects[object_path]) for property_name in invalidated_properties: - del self._objects[object_path][interface_name][property_name] + try: + del self._objects[object_path][interface_name][property_name] + except KeyError: + pass for key, value in changed_properties.items(): self._objects[object_path][interface_name][key] = value new_state = self._objects[object_path]