summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-05-10 12:55:30 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-05-10 12:55:30 +0100
commitcb4b0de49e027f09f8abe63e2fa43f60fc1ef13f (patch)
tree712da07b2b80fc503aea683c096a8774dceaad01 /django/utils
parentf6801a234fb9460eac80d146534ac340e178c466 (diff)
parentbdd285723f9b0044eca690634c412c1c3eec76c0 (diff)
Merge branch 'master' into schema-alteration
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/datastructures.py8
-rw-r--r--django/utils/functional.py1
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