Przeglądaj źródła

base: fix property-(pre-)del events arguments

oldvalue should contain the old value, even if it was default one. Same
as in property-(pre-)set events. If event want to check if that is
default value, it is always possible (in pre- event), but in practice
actual value is most useful.

This bug prevented netvm changing events from working when reseting
netvm.
Marek Marczykowski-Górecki 6 lat temu
rodzic
commit
98818b0ad9
1 zmienionych plików z 5 dodań i 2 usunięć
  1. 5 2
      qubes/__init__.py

+ 5 - 2
qubes/__init__.py

@@ -273,7 +273,7 @@ class property(object):  # pylint: disable=redefined-builtin,invalid-name
         self._enforce_write_once(instance)
 
         try:
-            oldvalue = getattr(instance, self._attr_name)
+            oldvalue = getattr(instance, self.__name__)
             has_oldvalue = True
         except AttributeError:
             has_oldvalue = False
@@ -282,7 +282,10 @@ class property(object):  # pylint: disable=redefined-builtin,invalid-name
             instance.fire_event('property-pre-del:' + self.__name__,
                 pre_event=True,
                 name=self.__name__, oldvalue=oldvalue)
-            delattr(instance, self._attr_name)
+            try:
+                delattr(instance, self._attr_name)
+            except AttributeError:
+                pass
             instance.fire_event('property-del:' + self.__name__,
                 name=self.__name__, oldvalue=oldvalue)