diff options
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/datastructures.py | 8 | ||||
| -rw-r--r-- | django/utils/functional.py | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index ec68892870..b0b1cd6b1d 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -14,13 +14,19 @@ class MergeDict(object): def __init__(self, *dicts): self.dicts = dicts + def __bool__(self): + return any(self.dicts) + + def __nonzero__(self): + return type(self).__bool__(self) + def __getitem__(self, key): for dict_ in self.dicts: try: return dict_[key] except KeyError: pass - raise KeyError + raise KeyError(key) def __copy__(self): return self.__class__(*self.dicts) diff --git a/django/utils/functional.py b/django/utils/functional.py index 13aec9cb82..1592828c7f 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -346,6 +346,7 @@ class SimpleLazyObject(LazyObject): # care about this (especially in equality tests) __class__ = property(new_method_proxy(operator.attrgetter("__class__"))) __eq__ = new_method_proxy(operator.eq) + __ne__ = new_method_proxy(operator.ne) __hash__ = new_method_proxy(hash) __bool__ = new_method_proxy(bool) # Python 3 __nonzero__ = __bool__ # Python 2 |
