Skip to content

Commit

Permalink
Merge pull request ipython#5220 from jasongrout/notify-check-2
Browse files Browse the repository at this point in the history
Make traitlets notify check more robust against classes redefining equality and bool
  • Loading branch information
minrk committed Feb 25, 2014
2 parents 31b9e77 + 624ab83 commit 684846f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions IPython/utils/traitlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,13 @@ def __set__(self, obj, value):
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):
Expand Down

0 comments on commit 684846f

Please sign in to comment.