Commit f1e4a501 authored by Nicolas Delaby's avatar Nicolas Delaby Committed by Cédric de Saint Martin

Add Support for options that contains `set` instances

This patch give ability for Options instances to support set objects
as values.
It define __eq__ to avoid calling the fallback method defined in UserDict upper class
ie: UserDict.__cmp__
(cherry picked from commit 4ca599db4e4dfe7f830747dce89d066a0d5d468f)
Signed-off-by: default avatarCédric de Saint Martin <cedric.dsm@tiolive.com>
parent 181aed38
......@@ -1427,6 +1427,20 @@ class Options(UserDict.DictMixin):
"""
return _convert_bool(name, self[name])
def __eq__(self, other):
"""Because __cmp__ calls cmp(self, other)
and if self contains set instance, it fails.
"""
if isinstance(other, (UserDict.DictMixin, dict)):
for item_self, item_other in itertools.izip_longest(
self.iteritems(),
other.iteritems()):
if item_self != item_other:
return False
return True
else:
return super(Options, self).__eq__(other)
def _convert_bool(name, value):
if value not in ('true', 'false'):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment