From 1c9655f712c1be4e7fa152b2c191e6fb16b9f19b 2014-02-25 16:59:12 From: Min RK Date: 2014-02-25 16:59:12 Subject: [PATCH] Merge pull request #5220 from jasongrout/notify-check-2 Make traitlets notify check more robust against classes redefining equality and bool --- diff --git a/IPython/utils/traitlets.py b/IPython/utils/traitlets.py index 6ebda18..86fb103 100644 --- a/IPython/utils/traitlets.py +++ b/IPython/utils/traitlets.py @@ -372,11 +372,13 @@ class TraitType(object): old_value = self.__get__(obj) obj._trait_values[self.name] = new_value try: - notify = (old_value != new_value) + silent = bool(old_value == new_value) except: # if there is an error in comparing, default to notify - notify = True - if notify: + silent = False + if silent is not True: + # we explicitly compare silent to True just in case the equality + # comparison above returns something other than True/False obj._notify_trait(self.name, old_value, new_value) def _validate(self, obj, value):