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.
This commit is contained in:
Marek Marczykowski-Górecki 2017-10-20 01:38:44 +02:00
parent 8f1bfa65f8
commit 98818b0ad9
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -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)