diff options
author | Sergei Trofimov <sergei.trofimov@arm.com> | 2018-06-14 14:46:48 +0100 |
---|---|---|
committer | setrofim <setrofim@gmail.com> | 2018-06-14 15:04:56 +0100 |
commit | 6ee40c217024607d808ca69ea1a6f0f3fa4f1f84 (patch) | |
tree | a6b84477aed67fd6128a4fb7f5934cd847058945 /wa/utils | |
parent | 64f9cf79e4a481810931ee91ec4bab122924147c (diff) |
utils/types: implement __ne__ for level
This should have been handled by the @total_ordering decorator, but
isn't due to
https://bugs.python.org/issue25732
(briefly, total_ordering is back-ported from Python 3, where the base
object provides the default implementation of __ne__ based on __eq__, so
total_ordering did not override it; this, however does not happen in
Python 2).
Also update unit tests to catch this edge case.
Diffstat (limited to 'wa/utils')
-rw-r--r-- | wa/utils/types.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/wa/utils/types.py b/wa/utils/types.py index 6256b9c9..c68d504c 100644 --- a/wa/utils/types.py +++ b/wa/utils/types.py @@ -569,6 +569,15 @@ class level(object): else: return self.value < other + def __ne__(self, other): + if isinstance(other, level): + return self.value != other.value + elif isinstance(other, basestring): + return self.name != other + else: + return self.value != other + + class _EnumMeta(type): |