diff options
Diffstat (limited to 'Lib/enum.py')
-rw-r--r-- | Lib/enum.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/enum.py b/Lib/enum.py index 04d8ec1fa8..9d1aef372c 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -303,6 +303,10 @@ class EnumMeta(type): return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start) def __contains__(cls, member): + if not isinstance(member, Enum): + raise TypeError( + "unsupported operand type(s) for 'in': '%s' and '%s'" % ( + type(member).__qualname__, cls.__class__.__qualname__)) return isinstance(member, cls) and member._name_ in cls._member_map_ def __delattr__(cls, attr): @@ -705,7 +709,9 @@ class Flag(Enum): def __contains__(self, other): if not isinstance(other, self.__class__): - return NotImplemented + raise TypeError( + "unsupported operand type(s) for 'in': '%s' and '%s'" % ( + type(other).__qualname__, self.__class__.__qualname__)) return other._value_ & self._value_ == other._value_ def __repr__(self): |